- probsUpdateLogistic() use var for multiplication

- automatic pattern reconstruction on pattern slider. Test button is obsolete
- revised sparse mode

git-svn-id: http://moon:8086/svn/software/trunk/projects/RBM@27 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
2014-10-15 20:35:49 +00:00
parent 005342e829
commit afc1853664
3 changed files with 9 additions and 5 deletions
+3 -2
View File
@@ -68,10 +68,11 @@ public:
void probsUpdateLogistic(Layer &layer, Weights &weights, double lambda, double sigma) void probsUpdateLogistic(Layer &layer, Weights &weights, double lambda, double sigma)
{ {
uint32_t i; uint32_t i;
double var = sigma*sigma;
for (i=0; i < m_numUnits; i++) for (i=0; i < m_numUnits; i++)
{ {
m_probs(i) = lambda/sigma*accum(layer, weights, i); m_probs(i) = lambda/var*accum(layer, weights, i);
} }
logSigmoid(m_probs); logSigmoid(m_probs);
} }
@@ -154,7 +155,7 @@ protected:
for (i=0; i < m_numUnits; i++) for (i=0; i < m_numUnits; i++)
{ {
double x2 = ((double)x[i]-mu); double x2 = ((double)x[i]-mu);
m_probs[i] = k*exp(-x2*x2/(2*var)); m_probs[i] = 1-exp(-x2*x2/(2*var));
} }
} }
}; };
+2 -1
View File
@@ -575,7 +575,8 @@ void MainComponent::sliderValueChanged (Slider* sliderThatWasMoved)
if (m_layers.getSize() > 0) if (m_layers.getSize() > 0)
{ {
VisibleLayer &p = (VisibleLayer&)m_layers.getAt((int)sliderThatWasMoved->getValue()); VisibleLayer &p = (VisibleLayer&)m_layers.getAt((int)sliderThatWasMoved->getValue());
DrawReconstruction->setData(p.states()); DrawTraining->setData(p.states());
redrawReconstruction();
} }
//[/UserSliderCode_patterSlider] //[/UserSliderCode_patterSlider]
} }
+4 -2
View File
@@ -210,9 +210,11 @@ public:
m += th.probs(); m += th.probs();
} }
m /= i; m /= i;
m.array() -= m_sparsity; th.states().array() = m.array() - m_sparsity;
th.states() = m;
hiddenBiasUpdate(th, -mu); hiddenBiasUpdate(th, -mu);
// cout << "Mean(" << m_sparsity << ") = " << (double)m.array().mean() << endl;
// cout << m << endl;
} }
if (sigma > sigmaMin) if (sigma > sigmaMin)
{ {