From 57cdfd706598ee14161b121881d9dad462c6a707 Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Thu, 7 Jul 2016 19:27:33 +0000 Subject: [PATCH] [RBM] - GUI: added gaussian hidden, added mini batch size - Rbm: added mini batch training revised sample functions, reverted to old weight decay git-svn-id: http://moon:8086/svn/software/trunk/projects/RBM@305 b431acfa-c32f-4a4a-93f1-934dc6c82436 --- Source/MainComponent.cpp | 53 ++++++++++-- Source/MainComponent.h | 2 + Source/Rbm.cpp | 180 ++++++++++++++++++++++----------------- Source/Rbm.hpp | 13 ++- 4 files changed, 161 insertions(+), 87 deletions(-) diff --git a/Source/MainComponent.cpp b/Source/MainComponent.cpp index 0ac58e3..c11825f 100644 --- a/Source/MainComponent.cpp +++ b/Source/MainComponent.cpp @@ -277,6 +277,20 @@ MainComponent::MainComponent () rbmDoSampleBatch->setButtonText (TRANS("Sample training")); rbmDoSampleBatch->addListener (this); + addAndMakeVisible (sizeMiniBatch = new Label ("sizeMiniBatch", + TRANS("0"))); + sizeMiniBatch->setTooltip (TRANS("Maximum number of training samples per train")); + sizeMiniBatch->setFont (Font (15.00f, Font::plain)); + sizeMiniBatch->setJustificationType (Justification::centred); + sizeMiniBatch->setEditable (true, true, false); + sizeMiniBatch->setColour (TextEditor::textColourId, Colours::black); + sizeMiniBatch->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); + sizeMiniBatch->addListener (this); + + addAndMakeVisible (rbmUseHiddenGaussianToggleButton = new ToggleButton ("rbmUseHiddenGaussian toggle button")); + rbmUseHiddenGaussianToggleButton->setButtonText (TRANS("Use gaussian hidden")); + rbmUseHiddenGaussianToggleButton->addListener (this); + //[UserPreSize] memset(m_pRbmComponent, 0, sizeof(m_pRbmComponent)); @@ -334,6 +348,8 @@ MainComponent::~MainComponent() rbmNormalizeDataToggleButton = nullptr; m_rbmSelect = nullptr; rbmDoSampleBatch = nullptr; + sizeMiniBatch = nullptr; + rbmUseHiddenGaussianToggleButton = nullptr; //[Destructor]. You can add your own custom destruction code here.. @@ -443,14 +459,16 @@ void MainComponent::resized() sparsityLabel->setBounds (740, 152, 72, 24); sigmaDecayLabel->setBounds (836, 152, 72, 24); weightDecayLabel->setBounds (836, 200, 72, 24); - m_progressBarSlider->setBounds (844, 20, 220, 24); + m_progressBarSlider->setBounds (828, 20, 220, 24); momentumLabel->setBounds (740, 200, 72, 24); sparsityLearningRateLabel->setBounds (948, 152, 72, 24); weightInitLabel->setBounds (948, 200, 72, 24); - rbmLearnVarianceButton->setBounds (976, 92, 128, 24); - rbmNormalizeDataToggleButton->setBounds (844, 92, 124, 24); + rbmLearnVarianceButton->setBounds (1004, 92, 128, 24); + rbmNormalizeDataToggleButton->setBounds (1004, 60, 124, 24); m_rbmSelect->setBounds (812, 280, 62, 24); rbmDoSampleBatch->setBounds (844, 60, 128, 24); + sizeMiniBatch->setBounds (1064, 20, 48, 24); + rbmUseHiddenGaussianToggleButton->setBounds (840, 92, 156, 24); //[UserResized] Add your own custom resize handling here.. //[/UserResized] } @@ -575,6 +593,12 @@ void MainComponent::buttonClicked (Button* buttonThatWasClicked) m_pRbmComponentCurr->setDoSampleBatch(buttonThatWasClicked->getToggleState()); //[/UserButtonCode_rbmDoSampleBatch] } + else if (buttonThatWasClicked == rbmUseHiddenGaussianToggleButton) + { + //[UserButtonCode_rbmUseHiddenGaussianToggleButton] -- add your button handler code here.. + m_pRbmComponentCurr->setUseHiddenGaussian(buttonThatWasClicked->getToggleState()); + //[/UserButtonCode_rbmUseHiddenGaussianToggleButton] + } //[UserbuttonClicked_Post] //[/UserbuttonClicked_Post] @@ -697,6 +721,12 @@ void MainComponent::labelTextChanged (Label* labelThatHasChanged) //[UserLabelCode_weightInitLabel] -- add your label text handling code here.. //[/UserLabelCode_weightInitLabel] } + else if (labelThatHasChanged == sizeMiniBatch) + { + //[UserLabelCode_sizeMiniBatch] -- add your label text handling code here.. + m_pRbmComponentCurr->setMiniBatchSize((size_t)labelThatHasChanged->getText().getFloatValue()); + //[/UserLabelCode_sizeMiniBatch] + } //[UserlabelTextChanged_Post] //[/UserlabelTextChanged_Post] @@ -867,6 +897,7 @@ void MainComponent::updateControls() rbmDoSampleVisibleToggleButton->setToggleState(m_pRbmComponentCurr->params().m_doSampleVisible, dontSendNotification); rbmDoSampleBatch->setToggleState(m_pRbmComponentCurr->params().m_doSampleBatch, dontSendNotification); rbmUseVisibleGaussianToggleButton->setToggleState(m_pRbmComponentCurr->params().m_useVisibleGaussian, dontSendNotification); + rbmUseHiddenGaussianToggleButton->setToggleState(m_pRbmComponentCurr->params().m_useHiddenGaussian, dontSendNotification); rbmDoSparseToggleButton->setToggleState(m_pRbmComponentCurr->params().m_doSparse, dontSendNotification); rbmLearnVarianceButton->setToggleState(m_pRbmComponentCurr->params().m_doLearnVariance, dontSendNotification); rbmDoSampleBatch->setToggleState(m_pRbmComponentCurr->params().m_doSampleBatch, dontSendNotification); @@ -882,6 +913,7 @@ void MainComponent::updateControls() numVisibleLabel->setText(String(m_weightsCurr->getNumVisibleX()), dontSendNotification ); numVisibleYLabel->setText(String(m_weightsCurr->getNumVisibleY()), dontSendNotification ); numHiddenLabel->setText(String(m_weightsCurr->getNumHidden()), dontSendNotification ); + sizeMiniBatch->setText(String(m_pRbmComponentCurr->params().m_miniBatchSize), dontSendNotification); WeightsSlider->setRange(0, m_weightsCurr->getNumHidden()-1, 1); numGibbsSlider->setValue(m_pRbmComponentCurr->params().m_numGibbs); @@ -1054,7 +1086,7 @@ BEGIN_JUCER_METADATA focusDiscardsChanges="0" fontname="Default font" fontsize="15" bold="0" italic="0" justification="36"/>