From afc1853664598559a57da6d82967ba225ea19509 Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Wed, 15 Oct 2014 20:35:49 +0000 Subject: [PATCH] - 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 --- Source/Layer.hpp | 5 +++-- Source/MainComponent.cpp | 3 ++- Source/Rbm.hpp | 6 ++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Source/Layer.hpp b/Source/Layer.hpp index 7a17884..e4b23dd 100644 --- a/Source/Layer.hpp +++ b/Source/Layer.hpp @@ -68,10 +68,11 @@ public: void probsUpdateLogistic(Layer &layer, Weights &weights, double lambda, double sigma) { uint32_t i; + double var = sigma*sigma; 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); } @@ -154,7 +155,7 @@ protected: for (i=0; i < m_numUnits; i++) { double x2 = ((double)x[i]-mu); - m_probs[i] = k*exp(-x2*x2/(2*var)); + m_probs[i] = 1-exp(-x2*x2/(2*var)); } } }; diff --git a/Source/MainComponent.cpp b/Source/MainComponent.cpp index fa54348..cb9aeda 100644 --- a/Source/MainComponent.cpp +++ b/Source/MainComponent.cpp @@ -575,7 +575,8 @@ void MainComponent::sliderValueChanged (Slider* sliderThatWasMoved) if (m_layers.getSize() > 0) { VisibleLayer &p = (VisibleLayer&)m_layers.getAt((int)sliderThatWasMoved->getValue()); - DrawReconstruction->setData(p.states()); + DrawTraining->setData(p.states()); + redrawReconstruction(); } //[/UserSliderCode_patterSlider] } diff --git a/Source/Rbm.hpp b/Source/Rbm.hpp index 8e60743..a42afe1 100644 --- a/Source/Rbm.hpp +++ b/Source/Rbm.hpp @@ -210,9 +210,11 @@ public: m += th.probs(); } m /= i; - m.array() -= m_sparsity; - th.states() = m; + th.states().array() = m.array() - m_sparsity; hiddenBiasUpdate(th, -mu); + +// cout << "Mean(" << m_sparsity << ") = " << (double)m.array().mean() << endl; +// cout << m << endl; } if (sigma > sigmaMin) {