30 #ifndef SHARK_UNSUPERVISED_RBM_SAMPLING_ESTEMPEREDMARKOVCHAIN_H 31 #define SHARK_UNSUPERVISED_RBM_SAMPLING_ESTEMPEREDMARKOVCHAIN_H 39 template<
class Operator>
42 typedef typename Operator::HiddenSample HiddenSample;
43 typedef typename Operator::VisibleSample VisibleSample;
53 typedef typename Operator::RBM
RBM;
68 bool m_storeEnergyDifferences;
69 bool m_integrateEnergyDifferences;
70 std::vector<RealVector> m_energyDiffUp;
71 std::vector<RealVector> m_energyDiffDown;
75 bool integrateEnergyDifferences =
true 77 , m_integrateEnergyDifferences(integrateEnergyDifferences)
78 , m_storeEnergyDifferences(true){}
110 double beta(std::size_t i)
const{
111 return m_chain.
beta(i);
115 return m_chain.
beta();
152 std::size_t numChains =
beta().size();
154 RealVector betaUp(numChains);
155 RealVector betaDown(numChains);
157 betaDown(numChains-1) = 0.0;
158 for(std::size_t i = 0; i != numChains-1; ++i){
159 betaDown(i) =
beta()(i+1);
160 betaUp(i+1) =
beta()(i);
163 RealVector energyDiffUp(numChains);
164 RealVector energyDiffDown(numChains);
165 if(!m_integrateEnergyDifferences){
166 noalias(energyDiffUp) =
samples().energy*(betaUp-
beta());
167 noalias(energyDiffDown) =
samples().energy*(betaDown-
beta());
177 noalias(energyDiffUp) = energyDiffDown;
191 m_energyDiffUp.push_back(energyDiffUp);
192 m_energyDiffDown.push_back(energyDiffDown);
196 RealMatrix diffUp(
beta().size(),m_energyDiffUp.size());
197 for(std::size_t i = 0; i != m_energyDiffUp.size(); ++i){
198 noalias(column(diffUp,i)) = m_energyDiffUp[i];
203 RealMatrix diffDown(
beta().size(),m_energyDiffDown.size());
204 for(std::size_t i = 0; i != m_energyDiffDown.size(); ++i){
205 noalias(column(diffDown,i)) = m_energyDiffDown[i];
211 m_energyDiffUp.clear();
212 m_energyDiffDown.clear();
216 return m_storeEnergyDifferences;