- more compact
- added Stack::weights init - create smaller test.prj git-svn-id: http://moon:8086/svn/software/trunk/projects/Rbm@596 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
+1
-2
@@ -110,8 +110,7 @@ void Rbm::train(const arma::mat& batch, size_t miniBatchSize, size_t numEpochs,
|
||||
vis_state = miniBatch;
|
||||
}
|
||||
|
||||
hid_state = toHiddenState(vis_state);
|
||||
hid_probs = probsLogistic(hid_state);
|
||||
hid_probs = probsLogistic(toHiddenState(vis_state));
|
||||
|
||||
// Sample hidden
|
||||
if (m_params.doRaoBlackwell)
|
||||
|
||||
@@ -115,6 +115,16 @@ bool Stack::save()
|
||||
return true;
|
||||
}
|
||||
|
||||
void Stack::weightsInit(double stddev)
|
||||
{
|
||||
Layer *pLayer = m_pLayers;
|
||||
while(pLayer)
|
||||
{
|
||||
pLayer->weightsInit(0, stddev);
|
||||
pLayer = pLayer->upper;
|
||||
}
|
||||
}
|
||||
|
||||
bool Stack::loadWeights()
|
||||
{
|
||||
Layer *pLayer = m_pLayers;
|
||||
|
||||
@@ -34,6 +34,7 @@ public:
|
||||
void train(const arma::mat& batch, size_t miniBatchSize, size_t numEpochs, Rbm::IListener* pListener);
|
||||
bool load();
|
||||
bool save();
|
||||
void weightsInit(double stddev);
|
||||
bool loadWeights();
|
||||
bool saveWeights();
|
||||
|
||||
|
||||
+8
-5
@@ -89,9 +89,9 @@ int main()
|
||||
size_t numTraining = batch.n_rows;
|
||||
printf("Loaded %d training samples\n", (int)numTraining);
|
||||
|
||||
#if 0
|
||||
#if 1
|
||||
int i = 0;
|
||||
Layer *lowerLayer = new Layer("Layer", i, 16, 16, 256);
|
||||
Layer *lowerLayer = new Layer("Layer", i, 16, 16, 8);
|
||||
stack.addLayer(lowerLayer);
|
||||
|
||||
for (++i; i < 1; i++)
|
||||
@@ -103,13 +103,16 @@ int main()
|
||||
|
||||
// Save project
|
||||
stack.save();
|
||||
|
||||
// Shake weights
|
||||
stack.weightsInit(0.01);
|
||||
#else
|
||||
// Load project
|
||||
stack.load();
|
||||
#endif
|
||||
|
||||
// Load weights
|
||||
stack.loadWeights();
|
||||
|
||||
#endif
|
||||
|
||||
// Train stack
|
||||
stack.train(batch, 1000, 1000, &statusDisplay);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user