- added button and functionality for Rao-Blackwellized weight update
- added button for Robins-Monro weight update git-svn-id: http://moon:8086/svn/software/trunk/projects/RBM@19 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
+19
-4
@@ -78,7 +78,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void train(LayerArray<VisibleLayer> &vts, uint32_t numEpochs, double mu, uint32_t numGibbs = 1, bool useExpectations=false)
|
||||
void train(LayerArray<VisibleLayer> &vts, uint32_t numEpochs, double mu, uint32_t numGibbs = 1, bool useExpectations = false, bool doRaoBlackwell = false, bool doRobinsMonro = false)
|
||||
{
|
||||
uint32_t t;
|
||||
uint32_t epoch;
|
||||
@@ -96,23 +96,38 @@ public:
|
||||
{
|
||||
// Create hidden layer base on training data
|
||||
h.probsUpdate(vts[t], w);
|
||||
h.statesUpdateStochastic();
|
||||
|
||||
// Update weights (positive phase)
|
||||
if (doRaoBlackwell)
|
||||
{
|
||||
h.statesAssignfromProbs();
|
||||
}
|
||||
else
|
||||
{
|
||||
h.statesUpdateStochastic();
|
||||
}
|
||||
weightsUpdate(vts[t], h, +mu/vts.getSize());
|
||||
|
||||
for (gibbs=0; gibbs < numGibbs; gibbs++)
|
||||
{
|
||||
h.statesUpdateStochastic();
|
||||
|
||||
// Create visible reconstruction (a fantasy...)
|
||||
v.probsUpdate(h, w);
|
||||
v.statesUpdateStochastic();
|
||||
|
||||
// Create hidden reconstruction
|
||||
h.probsUpdate(v, w);
|
||||
h.statesUpdateStochastic();
|
||||
}
|
||||
// Update weights (negative phase)
|
||||
h.statesAssignfromProbs();
|
||||
if (doRaoBlackwell)
|
||||
{
|
||||
h.statesAssignfromProbs();
|
||||
}
|
||||
else
|
||||
{
|
||||
h.statesUpdateStochastic();
|
||||
}
|
||||
weightsUpdate(v, h, -mu/vts.getSize());
|
||||
|
||||
if (!useExpectations)
|
||||
|
||||
Reference in New Issue
Block a user