[RBM]
- DBN fixes - batch sample inside training loop - implemented RbmComponent stacking git-svn-id: http://moon:8086/svn/software/trunk/projects/RBM@296 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
+14
-18
@@ -32,7 +32,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
virtual void onEpochTrained(const Rbm &obj) = 0;
|
||||
virtual void onProgressChanged(const Rbm &obj) = 0;
|
||||
};
|
||||
|
||||
class Rbm
|
||||
@@ -274,8 +274,6 @@ public:
|
||||
|
||||
MatrixXd diffErr(batchSize, m_w.getNumVisible());
|
||||
|
||||
m_progress = 0;
|
||||
|
||||
MatrixXd batch = m_batch;
|
||||
|
||||
if (m_params.m_doNormalizeData)
|
||||
@@ -288,14 +286,18 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_params.m_useProbsForHiddenReconstruction)
|
||||
{
|
||||
sample(batch);
|
||||
}
|
||||
|
||||
m_progress = 0;
|
||||
for (epoch=0; epoch < numEpochs; epoch++)
|
||||
{
|
||||
double err;
|
||||
if (m_pListener)
|
||||
{
|
||||
m_pListener->onProgressChanged(*this);
|
||||
}
|
||||
|
||||
if (!m_params.m_useProbsForHiddenReconstruction)
|
||||
{
|
||||
sample(batch, m_batch);
|
||||
}
|
||||
|
||||
// Create hidden layer base on training data
|
||||
toHiddenBatch(h, batch);
|
||||
@@ -311,7 +313,6 @@ public:
|
||||
sumBiasH = h.colwise().sum();
|
||||
}
|
||||
sumWeights = batch.transpose() * h;
|
||||
diffErr = batch;
|
||||
|
||||
for (gibbs=0; gibbs < m_params.m_numGibbs; gibbs++)
|
||||
{
|
||||
@@ -350,7 +351,6 @@ public:
|
||||
sumBiasH -= h.colwise().sum();
|
||||
}
|
||||
sumWeights -= m_v.transpose() * h;
|
||||
diffErr -= m_v;
|
||||
|
||||
deltaWeights = m_params.m_momentum*deltaWeights + m_params.m_muWeights*(kTrain*sumWeights - m_params.m_weightDecay*m_w.weights());
|
||||
m_w.weights() += deltaWeights;
|
||||
@@ -385,11 +385,12 @@ public:
|
||||
m_progress += dProgress;
|
||||
if (m_pListener)
|
||||
{
|
||||
m_pListener->onEpochTrained(*this);
|
||||
m_pListener->onProgressChanged(*this);
|
||||
}
|
||||
|
||||
diffErr = batch - m_v;
|
||||
diffErr.array() *= diffErr.array();
|
||||
err = diffErr.colwise().sum().sum();
|
||||
double err = diffErr.colwise().sum().sum();
|
||||
|
||||
cout << "err =" << endl;
|
||||
cout << err << endl;
|
||||
@@ -445,11 +446,6 @@ public:
|
||||
m_variableSigma.fill(m_params.m_constantSigma);
|
||||
}
|
||||
|
||||
double getConstantSigma()
|
||||
{
|
||||
return m_params.m_constantSigma;
|
||||
}
|
||||
|
||||
RowVectorXd& getVariableSigma()
|
||||
{
|
||||
return m_variableSigma;
|
||||
|
||||
Reference in New Issue
Block a user