- moved context awareness from Rbm to Layer

git-svn-id: http://moon:8086/svn/software/trunk/projects/Rbm@769 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
2022-01-10 08:09:49 +00:00
parent 967df2906d
commit e9de02ac3d
3 changed files with 20 additions and 23 deletions
+18 -2
View File
@@ -37,8 +37,24 @@ public:
void train(arma::mat const &batch, IListener *pListener=nullptr)
{
if (batch.n_rows > 0)
{
Rbm::train(trainingData(batch), pListener);
{
if (numContext())
{
arma::mat c_states = arma::zeros(batch.n_rows, numContext());
arma::mat ctx = arma::zeros(1, 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;
c_states.row(i) = ctx;
}
arma::mat batch_with_ctx = arma::join_rows(batch, c_states);
Rbm::train(trainingData(batch_with_ctx), pListener);
}
else
{
Rbm::train(trainingData(batch), pListener);
}
}
}