- integrated RnnStack
git-svn-id: http://moon:8086/svn/software/trunk/projects/Rbm@826 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
+19
-5
@@ -9,7 +9,7 @@
|
||||
#include <jsoncpp/json/json.h>
|
||||
#include "Rbm.hpp"
|
||||
#include "Layer.hpp"
|
||||
#include "DeepStack.hpp"
|
||||
#include "RnnStack.hpp"
|
||||
#include "StackCreator.hpp"
|
||||
|
||||
using namespace std;
|
||||
@@ -140,11 +140,11 @@ arma::mat createTraining(const string &filename, size_t seq_len)
|
||||
struct Rnn
|
||||
{
|
||||
Rnn(Layer *layer)
|
||||
: nV(layer->numVisible() - layer->context().n_cols)
|
||||
: nV(layer->numVisible() - layer->numHidden())
|
||||
, nH(layer->numHidden())
|
||||
, nVx(layer->numVisibleX())
|
||||
, nVy(layer->numVisibleY())
|
||||
, nC(layer->context().n_cols)
|
||||
, nC(layer->numHidden())
|
||||
{
|
||||
|
||||
}
|
||||
@@ -192,6 +192,7 @@ arma::mat to_next(arma::mat v)
|
||||
}
|
||||
|
||||
#define CREATE_TRAINING 0
|
||||
#define DO_TRAINING 1
|
||||
int main()
|
||||
{
|
||||
#if CREATE_TRAINING
|
||||
@@ -201,7 +202,7 @@ int main()
|
||||
#endif
|
||||
|
||||
// Load project
|
||||
AStack *stack = StackCreator::fromFile(".", "poet5");
|
||||
RnnStack *stack = reinterpret_cast<RnnStack*>(StackCreator::fromFile(".", "poet2"));
|
||||
|
||||
// Load weights
|
||||
stack->loadWeights(".");
|
||||
@@ -209,6 +210,19 @@ int main()
|
||||
// Load training
|
||||
stack->loadTrainingBatch(".");
|
||||
|
||||
#if DO_TRAINING
|
||||
RbmListener listener;
|
||||
arma::mat t_vc = stack->trainingBatch();
|
||||
|
||||
for (int i=0; i < stack->getSeqLen(); i++)
|
||||
{
|
||||
stack->getLayer(i)->weightsInit(0.1,0);
|
||||
stack->train(i, t_vc, &listener);
|
||||
}
|
||||
stack->saveWeights(".");
|
||||
stack->save(".");
|
||||
|
||||
#else
|
||||
Layer *layer = stack->getLayer(0);
|
||||
int numTraining = stack->trainingBatch().n_rows;
|
||||
|
||||
@@ -268,7 +282,7 @@ int main()
|
||||
putchar(c);
|
||||
}
|
||||
|
||||
#endif
|
||||
printf("\n\nEnd of program\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user