107 std::size_t batches = m_samples / m_batchSize;
108 if(m_samples - batches*m_batchSize != 0){
111 m_chains.resize(batches);
114 for(std::size_t i = 0; i != batches;++i){
115 swap(m_chains[i],m_chainOperator.samples());
116 std::size_t currentBatchSize = std::min(m_samples-i*m_batchSize, m_batchSize);
117 m_chainOperator.setBatchSize(currentBatchSize);
118 m_chainOperator.initializeChain(m_data);
119 swap(m_chains[i],m_chainOperator.samples());
137 mpe_rbm->setParameterVector(parameter);
140 RealVector empiricalAverage = detail::evaluateData(m_data,*mpe_rbm,m_numBatches);
144 for(std::size_t i = 0; i != m_chains.size();++i){
145 swap(m_chains[i],m_chainOperator.samples());
146 m_chainOperator.step(m_k);
147 modelAverage.addVH(m_chainOperator.samples().hidden, m_chainOperator.samples().visible);
148 swap(m_chains[i],m_chainOperator.samples());
151 derivative.resize(mpe_rbm->numberOfParameters());
152 noalias(derivative) = modelAverage.result() - empiricalAverage;
157 noalias(derivative) += m_regularizationStrength*regularizerDerivative;
160 return std::numeric_limits<double>::quiet_NaN();