diff --git a/Source/LayerArray.hpp b/Source/LayerArray.hpp index 45218f0..70e8718 100644 --- a/Source/LayerArray.hpp +++ b/Source/LayerArray.hpp @@ -72,6 +72,20 @@ public: } } + LayerArray (const LayerArray &rhs) + : m_size(0) + , m_pRoot(nullptr) + , m_ppIndex(nullptr) + , m_pListener(nullptr) + { + uint32_t i; + + for (i=0; i < rhs.getSize(); i++) + { + this->add(&rhs[i].states(), rhs[i].states().size()); + } + } + virtual ~LayerArray() { m_pListener = nullptr; @@ -125,12 +139,12 @@ public: m_pListener->onChanged(*this); } - T& getAt(uint32_t index) + T& getAt(uint32_t index) const { return *m_ppIndex[index]; } - T& operator[](uint32_t index) + T& operator[](uint32_t index) const { return getAt(index); } diff --git a/Source/MainComponent.cpp b/Source/MainComponent.cpp index 2b8f828..67717f1 100644 --- a/Source/MainComponent.cpp +++ b/Source/MainComponent.cpp @@ -477,10 +477,7 @@ void MainComponent::buttonClicked (Button* buttonThatWasClicked) if (buttonThatWasClicked == trainButton) { //[UserButtonCode_trainButton] -- add your button handler code here.. -// m_pRbm->train(m_layers, numEpochslabel->getText().getIntValue(), learningRateLabel->getText().getFloatValue(), m_numGibbs); startThread(); - redrawReconstruction(); - redrawWeights((int)WeightsSlider->getValue()); //[/UserButtonCode_trainButton] } else if (buttonThatWasClicked == addButton) diff --git a/Source/Rbm.hpp b/Source/Rbm.hpp index 8d94873..e7e8fb0 100644 --- a/Source/Rbm.hpp +++ b/Source/Rbm.hpp @@ -63,7 +63,7 @@ public: Noise_Free(&m_noise); } - void train(LayerArray &vt, uint32_t numEpochs, double sigmaMin = 0.05) + void train(const LayerArray &batch, uint32_t numEpochs, double sigmaMin = 0.05) { uint32_t t, i; uint32_t epoch; @@ -81,6 +81,8 @@ public: MatrixXd sumWeights(m_w.getNumVisible(), m_w.getNumHidden()); MatrixXd deltaWeights(m_w.getNumVisible(), m_w.getNumHidden()); + const LayerArray &vt = batch; + sigma = m_sigma; double dProgress = 1.0/numEpochs;