- added calculateContextBatch

- trainingdata always contains context
- load / store training batch with context
- on load: add context part to  legacy training batches 
- removed Rbm::setBatch()

git-svn-id: http://moon:8086/svn/software/trunk/projects/Rbm@789 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
2022-01-12 08:12:19 +00:00
parent 67815bf5c6
commit c88ab5336b
+9 -18
View File
@@ -32,26 +32,17 @@ public:
Json::Value toJson() const;
void setBatch(arma::mat const &batch)
void calcContextBatch(arma::mat &batch)
{
if (batch.n_rows > 0)
{
if (m_numContext)
size_t numTraining = batch.n_rows;
if (m_numContext > 0 and numTraining > 0)
{
for (int i=1; i < numTraining; i++)
{
m_context = arma::zeros(batch.n_rows, m_numContext);
arma::mat ctx = arma::zeros(1, m_numContext);
for (int i=1; i < batch.n_rows; i++)
{
arma::mat h = prob(v_to_h(arma::join_rows(batch.row(i-1), ctx)));
ctx = h;
m_context.row(i) = ctx;
}
arma::mat batch_with_ctx = arma::join_rows(batch, m_context);
Rbm::setBatch(trainingData(batch_with_ctx));
}
else
{
Rbm::setBatch(trainingData(batch));
arma::mat h = toHiddenProbs(batch.row(i-1));
arma::mat training_with_ctx = arma::join_rows(batch.row(i-1).cols(0, numVisible()-m_numContext-1), h);
batch.row(i-1) = training_with_ctx;
}
}
}