- 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:
+18
-2
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user