112 mpe_rbm->setParameterVector(parameter);
115 RealVector empiricalAverage = detail::evaluateData(m_data,*mpe_rbm,m_numBatches);
121 std::size_t samplesToDraw = m_samples > 0 ? m_samples: m_data.
numberOfElements();
123 std::size_t batches = samplesToDraw / m_batchSize;
124 if(samplesToDraw - batches*m_batchSize != 0){
133 for(std::size_t batch = 0; batch != batches; ++batch){
135 std::size_t currentBatchSize = std::min(samplesToDraw-batch*m_batchSize, m_batchSize);
136 typename MarkovChainType::SampleBatch gradientBatch(currentBatchSize, mpe_rbm->numberOfVN(),mpe_rbm->numberOfHN());
138 for(std::size_t i = 0; i != currentBatchSize; ++i){
143 modelAverage.addVH(gradientBatch.hidden, gradientBatch.visible);
146 derivative.resize(mpe_rbm->numberOfParameters());
147 noalias(derivative) = modelAverage.result() - empiricalAverage;
152 noalias(derivative) += m_regularizationStrength*regularizerDerivative;
155 return std::numeric_limits<double>::quiet_NaN();