From 6ccffc119d54fb8eb71bf69659daeca4f3ff8eb8 Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Thu, 7 Nov 2019 16:35:00 +0000 Subject: [PATCH] - cleaned up git-svn-id: http://moon:8086/svn/software/trunk/projects/Rbm@625 b431acfa-c32f-4a4a-93f1-934dc6c82436 --- source/MainComponent.cpp | 5 +-- source/RbmComponent.cpp | 27 ++-------------- source/RbmComponent.hpp | 18 +++++------ test.prj | 68 +--------------------------------------- 4 files changed, 13 insertions(+), 105 deletions(-) diff --git a/source/MainComponent.cpp b/source/MainComponent.cpp index 27570fe..7f2a939 100644 --- a/source/MainComponent.cpp +++ b/source/MainComponent.cpp @@ -617,13 +617,14 @@ void MainComponent::sliderValueChanged (Slider* sliderThatWasMoved) { //[UserSliderCode_patterSlider] -- add your slider handling code here.. m_trainingIndex = (int)sliderThatWasMoved->getValue(); - m_pLayer->setTrainingIndex(m_trainingData.row(m_trainingIndex)); + m_pLayer->setTrainingData(m_trainingData.row(m_trainingIndex)); //[/UserSliderCode_patterSlider] } else if (sliderThatWasMoved == WeightsSlider) { //[UserSliderCode_WeightsSlider] -- add your slider handling code here.. - m_weightIndex = (int)sliderThatWasMoved->getValue(); + int weightIndex = (int)sliderThatWasMoved->getValue(); + m_pLayer->redrawWeights(weightIndex); //[/UserSliderCode_WeightsSlider] } else if (sliderThatWasMoved == numGibbsSlider) diff --git a/source/RbmComponent.cpp b/source/RbmComponent.cpp index 3a97a27..9a76adb 100644 --- a/source/RbmComponent.cpp +++ b/source/RbmComponent.cpp @@ -26,7 +26,6 @@ RbmComponent::RbmComponent (const std::string &name, size_t id, size_t numVisibleX, size_t numVisibleY, size_t numHidden, RbmComponentListener *pListener) : Layer(name, id, numVisibleX, numVisibleY, numHidden) , m_currWeightIndexToDraw(0) - , m_currTrainingIndexToDraw(0) , DrawTraining(nullptr) , DrawReconstruction(nullptr) , DrawWeights(nullptr) @@ -249,24 +248,12 @@ void RbmComponent::redrawWeights() DrawWeights->DrawData(); } -void RbmComponent::onParamsChanged() -{ - redrawWeights(); - redrawReconstruction(); -} - -void RbmComponent::setWeightsIndex(size_t index) +void RbmComponent::redrawWeights(size_t index) { m_currWeightIndexToDraw = index; - redrawWeights(); } -size_t RbmComponent::getWeightsIndex() -{ - return m_currWeightIndexToDraw; -} - -void RbmComponent::setTrainingIndex(arma::mat const& batch) +void RbmComponent::setTrainingData(arma::mat const& batch) { DrawTraining->getData() = batch; DrawTraining->DrawData(); @@ -275,16 +262,6 @@ void RbmComponent::setTrainingIndex(arma::mat const& batch) upPass(DrawHidden->getData()); } -size_t RbmComponent::getTrainingIndex() -{ - return m_currTrainingIndexToDraw; -} - -arma::mat const& RbmComponent::getTrainingData() -{ - return DrawTraining->getData(); -} - arma::mat const& RbmComponent::getTopWeights() { if (upper) diff --git a/source/RbmComponent.hpp b/source/RbmComponent.hpp index 355d239..8574a2b 100644 --- a/source/RbmComponent.hpp +++ b/source/RbmComponent.hpp @@ -98,15 +98,17 @@ public: void mouseDoubleClick (const MouseEvent& e) override; void mouseWheelMove (const MouseEvent& e, const MouseWheelDetails& wheel) override; - void setWeightsIndex(size_t index); - size_t getWeightsIndex(); + void train(const arma::mat& batch) + { + Layer::train(batch, this); + } - void setTrainingIndex(arma::mat const& batch); - size_t getTrainingIndex(); + void setTrainingData(arma::mat const& batch); void redrawWeights(); + void redrawWeights(size_t index); + void redrawReconstruction(); - arma::mat const& getTrainingData(); void downPass(arma::mat &dst, arma::mat const &src) override { @@ -133,10 +135,6 @@ public: arma::mat getConvolutedWeight(arma::mat const &h) override; arma::mat const& getWeights() override; - void train(const arma::mat& batch) - { - Layer::train(batch, this); - } private: //[UserVariables] -- You can add your own custom variables in this section. RbmComponentListener *m_listener; @@ -145,8 +143,6 @@ private: ScopedPointer DrawWeights; ScopedPointer DrawHidden; size_t m_currWeightIndexToDraw; - size_t m_currTrainingIndexToDraw; - void onParamsChanged(); bool onProgress(const Rbm::Status &status) override; void onDraw(DrawComponent &obj) override; //[/UserVariables] diff --git a/test.prj b/test.prj index 6d7e1b3..b90d19c 100644 --- a/test.prj +++ b/test.prj @@ -22,74 +22,8 @@ } }, "weights_file" : "Layer.0.weights.dat" - }, - { - "id" : 1, - "name" : "Layer", - "numHidden" : 4, - "numVisibleX" : 8, - "numVisibleY" : 1, - "rbm" : { - "params" : { - "doRaoBlackwell" : 1, - "doSampleBatch" : 0, - "gibbsDoSampleHidden" : 1, - "gibbsDoSampleVisible" : 0, - "learningRate" : 0.050000000000000003, - "miniBatchSize" : 100, - "momentum" : 0.5, - "numEpochs" : 500, - "numGibbs" : 1, - "weightDecay" : 0 - } - }, - "weights_file" : "Layer.1.weights.dat" - }, - { - "id" : 2, - "name" : "Layer", - "numHidden" : 2, - "numVisibleX" : 4, - "numVisibleY" : 1, - "rbm" : { - "params" : { - "doRaoBlackwell" : 1, - "doSampleBatch" : 0, - "gibbsDoSampleHidden" : 1, - "gibbsDoSampleVisible" : 0, - "learningRate" : 0.025000000000000001, - "miniBatchSize" : 100, - "momentum" : 0.5, - "numEpochs" : 250, - "numGibbs" : 1, - "weightDecay" : 0 - } - }, - "weights_file" : "Layer.2.weights.dat" - }, - { - "id" : 3, - "name" : "Layer", - "numHidden" : 1, - "numVisibleX" : 2, - "numVisibleY" : 1, - "rbm" : { - "params" : { - "doRaoBlackwell" : 1, - "doSampleBatch" : 0, - "gibbsDoSampleHidden" : 1, - "gibbsDoSampleVisible" : 0, - "learningRate" : 0.012500000000000001, - "miniBatchSize" : 100, - "momentum" : 0.5, - "numEpochs" : 125, - "numGibbs" : 1, - "weightDecay" : 0 - } - }, - "weights_file" : "Layer.3.weights.dat" } - ], + ] "name" : "test" } }