- 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:
+9
-18
@@ -32,26 +32,17 @@ public:
|
|||||||
|
|
||||||
Json::Value toJson() const;
|
Json::Value toJson() const;
|
||||||
|
|
||||||
void setBatch(arma::mat const &batch)
|
void calcContextBatch(arma::mat &batch)
|
||||||
{
|
{
|
||||||
if (batch.n_rows > 0)
|
size_t numTraining = batch.n_rows;
|
||||||
{
|
|
||||||
if (m_numContext)
|
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 h = toHiddenProbs(batch.row(i-1));
|
||||||
arma::mat ctx = arma::zeros(1, m_numContext);
|
arma::mat training_with_ctx = arma::join_rows(batch.row(i-1).cols(0, numVisible()-m_numContext-1), h);
|
||||||
for (int i=1; i < batch.n_rows; i++)
|
batch.row(i-1) = training_with_ctx;
|
||||||
{
|
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user