- added param sparsity
- added gaussian visible unit - added param sigma decay - RBM modi and params are set using members - use sigma instead of variance git-svn-id: http://moon:8086/svn/software/trunk/projects/RBM@25 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
+298
-108
@@ -52,14 +52,12 @@ void mylog(const char* format, ...)
|
||||
|
||||
//[/MiscUserDefs]
|
||||
|
||||
using namespace Eigen;
|
||||
using namespace std;
|
||||
//==============================================================================
|
||||
MainComponent::MainComponent ()
|
||||
: m_layers(this),
|
||||
m_pRbm(nullptr),
|
||||
Draw(nullptr),
|
||||
Draw2(nullptr),
|
||||
DrawTraining(nullptr),
|
||||
DrawReconstruction(nullptr),
|
||||
DrawWeights(nullptr),
|
||||
DrawHidden(nullptr)
|
||||
{
|
||||
@@ -92,7 +90,7 @@ MainComponent::MainComponent ()
|
||||
WeightsSlider->addListener (this);
|
||||
|
||||
addAndMakeVisible (numEpochslabel = new Label ("Num Epochs label",
|
||||
TRANS("99999")));
|
||||
TRANS("100")));
|
||||
numEpochslabel->setFont (Font (15.00f, Font::plain));
|
||||
numEpochslabel->setJustificationType (Justification::centred);
|
||||
numEpochslabel->setEditable (true, true, false);
|
||||
@@ -101,7 +99,7 @@ MainComponent::MainComponent ()
|
||||
numEpochslabel->addListener (this);
|
||||
|
||||
addAndMakeVisible (learningRateLabel = new Label ("Learning Rate label",
|
||||
TRANS("0.001")));
|
||||
TRANS("0.03")));
|
||||
learningRateLabel->setFont (Font (15.00f, Font::plain));
|
||||
learningRateLabel->setJustificationType (Justification::centred);
|
||||
learningRateLabel->setEditable (true, true, false);
|
||||
@@ -136,7 +134,7 @@ MainComponent::MainComponent ()
|
||||
createButton->addListener (this);
|
||||
|
||||
addAndMakeVisible (projectNameLabel = new Label ("Project Name label",
|
||||
TRANS("ProjectName")));
|
||||
TRANS("TestPrj")));
|
||||
projectNameLabel->setFont (Font (15.00f, Font::plain));
|
||||
projectNameLabel->setJustificationType (Justification::centred);
|
||||
projectNameLabel->setEditable (true, true, false);
|
||||
@@ -203,6 +201,50 @@ MainComponent::MainComponent ()
|
||||
rbmReduceVarianceToggleButton->setButtonText (TRANS("Reduce Variance"));
|
||||
rbmReduceVarianceToggleButton->addListener (this);
|
||||
|
||||
addAndMakeVisible (lambdaLabel = new Label ("Lambda label",
|
||||
TRANS("1.0")));
|
||||
lambdaLabel->setFont (Font (15.00f, Font::plain));
|
||||
lambdaLabel->setJustificationType (Justification::centred);
|
||||
lambdaLabel->setEditable (true, true, false);
|
||||
lambdaLabel->setColour (TextEditor::textColourId, Colours::black);
|
||||
lambdaLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
|
||||
lambdaLabel->addListener (this);
|
||||
|
||||
addAndMakeVisible (sigmaLabel = new Label ("Sigma label",
|
||||
TRANS("0.5")));
|
||||
sigmaLabel->setFont (Font (15.00f, Font::plain));
|
||||
sigmaLabel->setJustificationType (Justification::centred);
|
||||
sigmaLabel->setEditable (true, true, false);
|
||||
sigmaLabel->setColour (TextEditor::textColourId, Colours::black);
|
||||
sigmaLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
|
||||
sigmaLabel->addListener (this);
|
||||
|
||||
addAndMakeVisible (rbmUseVisibleGaussianToggleButton = new ToggleButton ("rbmUseVisibleGaussian toggle button"));
|
||||
rbmUseVisibleGaussianToggleButton->setButtonText (TRANS("Use gaussian visible"));
|
||||
rbmUseVisibleGaussianToggleButton->addListener (this);
|
||||
|
||||
addAndMakeVisible (rbmDoSparseToggleButton = new ToggleButton ("rbmDoSparse toggle button"));
|
||||
rbmDoSparseToggleButton->setButtonText (TRANS("Do sparse"));
|
||||
rbmDoSparseToggleButton->addListener (this);
|
||||
|
||||
addAndMakeVisible (sparsityLabel = new Label ("Sparsity label",
|
||||
TRANS("0.05")));
|
||||
sparsityLabel->setFont (Font (15.00f, Font::plain));
|
||||
sparsityLabel->setJustificationType (Justification::centred);
|
||||
sparsityLabel->setEditable (true, true, false);
|
||||
sparsityLabel->setColour (TextEditor::textColourId, Colours::black);
|
||||
sparsityLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
|
||||
sparsityLabel->addListener (this);
|
||||
|
||||
addAndMakeVisible (sigmaDecayLabel = new Label ("SigmaDecay label",
|
||||
TRANS("1.0")));
|
||||
sigmaDecayLabel->setFont (Font (15.00f, Font::plain));
|
||||
sigmaDecayLabel->setJustificationType (Justification::centred);
|
||||
sigmaDecayLabel->setEditable (true, true, false);
|
||||
sigmaDecayLabel->setColour (TextEditor::textColourId, Colours::black);
|
||||
sigmaDecayLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
|
||||
sigmaDecayLabel->addListener (this);
|
||||
|
||||
|
||||
//[UserPreSize]
|
||||
m_vNumX = 16;
|
||||
@@ -217,19 +259,12 @@ MainComponent::MainComponent ()
|
||||
|
||||
//[/UserPreSize]
|
||||
|
||||
setSize (600, 400);
|
||||
setSize (800, 600);
|
||||
|
||||
|
||||
//[Constructor] You can add your own custom stuff here..
|
||||
|
||||
projectNameLabel->setText(String("TestPrj"), dontSendNotification );
|
||||
numEpochslabel->setText(String(100), dontSendNotification );
|
||||
learningRateLabel->setText(String(0.1), dontSendNotification );
|
||||
rbmUseExpectationsToggleButton->setToggleState(false, sendNotification);
|
||||
rbmDoRaoBlackwellToggleButton->setToggleState(false, sendNotification);
|
||||
rbmDoRobbinsMonroToggleButton->setToggleState(false, sendNotification);
|
||||
rbmReduceVarianceToggleButton->setToggleState(false, sendNotification);
|
||||
//[/Constructor]
|
||||
//[/Constructor]
|
||||
}
|
||||
|
||||
MainComponent::~MainComponent()
|
||||
@@ -263,11 +298,17 @@ MainComponent::~MainComponent()
|
||||
rbmDoRaoBlackwellToggleButton = nullptr;
|
||||
rbmDoRobbinsMonroToggleButton = nullptr;
|
||||
rbmReduceVarianceToggleButton = nullptr;
|
||||
lambdaLabel = nullptr;
|
||||
sigmaLabel = nullptr;
|
||||
rbmUseVisibleGaussianToggleButton = nullptr;
|
||||
rbmDoSparseToggleButton = nullptr;
|
||||
sparsityLabel = nullptr;
|
||||
sigmaDecayLabel = nullptr;
|
||||
|
||||
|
||||
//[Destructor]. You can add your own custom destruction code here..
|
||||
Draw = nullptr;
|
||||
Draw2 = nullptr;
|
||||
DrawTraining = nullptr;
|
||||
DrawReconstruction = nullptr;
|
||||
DrawWeights = nullptr;
|
||||
DrawHidden = nullptr;
|
||||
m_pRbm = nullptr;
|
||||
@@ -283,41 +324,83 @@ void MainComponent::paint (Graphics& g)
|
||||
|
||||
g.fillAll (Colours::white);
|
||||
|
||||
g.setColour (Colours::black);
|
||||
g.setFont (Font (15.00f, Font::plain));
|
||||
g.drawText (TRANS("Sigma"),
|
||||
32, 306, 80, 14,
|
||||
Justification::centred, true);
|
||||
|
||||
g.setColour (Colours::black);
|
||||
g.setFont (Font (15.00f, Font::plain));
|
||||
g.drawText (TRANS("Lambda"),
|
||||
120, 306, 80, 14,
|
||||
Justification::centred, true);
|
||||
|
||||
g.setColour (Colours::black);
|
||||
g.setFont (Font (15.00f, Font::plain));
|
||||
g.drawText (TRANS("Num. epochs"),
|
||||
32, 354, 80, 14,
|
||||
Justification::centred, true);
|
||||
|
||||
g.setColour (Colours::black);
|
||||
g.setFont (Font (15.00f, Font::plain));
|
||||
g.drawText (TRANS("Alpha"),
|
||||
120, 354, 80, 14,
|
||||
Justification::centred, true);
|
||||
|
||||
g.setColour (Colours::black);
|
||||
g.setFont (Font (15.00f, Font::plain));
|
||||
g.drawText (TRANS("Sparsity"),
|
||||
208, 306, 80, 14,
|
||||
Justification::centred, true);
|
||||
|
||||
g.setColour (Colours::black);
|
||||
g.setFont (Font (15.00f, Font::plain));
|
||||
g.drawText (TRANS("Sigma decay"),
|
||||
296, 306, 96, 14,
|
||||
Justification::centred, true);
|
||||
|
||||
//[UserPaint] Add your own custom painting code here..
|
||||
//[/UserPaint]
|
||||
}
|
||||
|
||||
void MainComponent::resized()
|
||||
{
|
||||
trainButton->setBounds (120, 312, 72, 24);
|
||||
trainButton->setBounds (120, 408, 72, 24);
|
||||
addButton->setBounds (24, 160, 72, 24);
|
||||
patterSlider->setBounds (224, 312, 184, 24);
|
||||
reconstructButton->setBounds (24, 312, 72, 24);
|
||||
ShakeButton->setBounds (120, 352, 72, 24);
|
||||
WeightsSlider->setBounds (224, 352, 184, 24);
|
||||
numEpochslabel->setBounds (24, 280, 72, 24);
|
||||
learningRateLabel->setBounds (120, 280, 72, 24);
|
||||
patterSlider->setBounds (224, 408, 184, 24);
|
||||
reconstructButton->setBounds (24, 408, 72, 24);
|
||||
ShakeButton->setBounds (120, 448, 72, 24);
|
||||
WeightsSlider->setBounds (224, 448, 184, 24);
|
||||
numEpochslabel->setBounds (32, 368, 72, 24);
|
||||
learningRateLabel->setBounds (120, 368, 72, 24);
|
||||
testButton->setBounds (120, 160, 72, 24);
|
||||
numVisibleLabel->setBounds (440, 256, 72, 24);
|
||||
numHiddenLabel->setBounds (488, 288, 72, 24);
|
||||
createButton->setBounds (488, 320, 72, 24);
|
||||
projectNameLabel->setBounds (472, 224, 96, 24);
|
||||
loadButton->setBounds (440, 192, 72, 24);
|
||||
saveButton->setBounds (520, 192, 72, 24);
|
||||
numVisibleYLabel->setBounds (512, 256, 72, 24);
|
||||
numVisibleLabel->setBounds (456, 328, 72, 24);
|
||||
numHiddenLabel->setBounds (504, 360, 72, 24);
|
||||
createButton->setBounds (504, 392, 72, 24);
|
||||
projectNameLabel->setBounds (488, 296, 96, 24);
|
||||
loadButton->setBounds (456, 264, 72, 24);
|
||||
saveButton->setBounds (536, 264, 72, 24);
|
||||
numVisibleYLabel->setBounds (528, 328, 72, 24);
|
||||
loadTrainingButton->setBounds (440, 48, 72, 24);
|
||||
saveTrainingButton->setBounds (520, 48, 72, 24);
|
||||
clearTrainingButton->setBounds (520, 88, 72, 24);
|
||||
removeTrainingButton->setBounds (440, 88, 72, 24);
|
||||
numGibbsSlider->setBounds (224, 272, 184, 24);
|
||||
reconstructEquButton->setBounds (24, 352, 72, 24);
|
||||
numGibbsSlider->setBounds (224, 368, 184, 24);
|
||||
reconstructEquButton->setBounds (24, 448, 72, 24);
|
||||
rbmUseExpectationsToggleButton->setBounds (24, 232, 128, 24);
|
||||
rbmDoRaoBlackwellToggleButton->setBounds (24, 200, 112, 24);
|
||||
rbmDoRobbinsMonroToggleButton->setBounds (168, 232, 120, 24);
|
||||
rbmReduceVarianceToggleButton->setBounds (168, 200, 128, 24);
|
||||
lambdaLabel->setBounds (120, 320, 72, 24);
|
||||
sigmaLabel->setBounds (32, 320, 72, 24);
|
||||
rbmUseVisibleGaussianToggleButton->setBounds (168, 264, 160, 24);
|
||||
rbmDoSparseToggleButton->setBounds (24, 264, 128, 24);
|
||||
sparsityLabel->setBounds (208, 320, 72, 24);
|
||||
sigmaDecayLabel->setBounds (304, 320, 72, 24);
|
||||
//[UserResized] Add your own custom resize handling here..
|
||||
Draw->setBounds (16, 16, 100, 100);
|
||||
Draw2->setBounds (110+16, 16, 100, 100);
|
||||
DrawTraining->setBounds (16, 16, 100, 100);
|
||||
DrawReconstruction->setBounds (110+16, 16, 100, 100);
|
||||
DrawWeights->setBounds (220+16, 16, 100, 100);
|
||||
DrawHidden->setBounds (16, 16+110, 320, 20);
|
||||
//[/UserResized]
|
||||
@@ -331,34 +414,38 @@ 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, m_rbmUseExpectations, m_rbmDoRaoBlackwell, m_rbmReduceEstimatorVariance, m_rbmDoRobbinsMonro);
|
||||
m_pRbm->train(m_layers, numEpochslabel->getText().getIntValue(), learningRateLabel->getText().getFloatValue(), m_numGibbs);
|
||||
redrawReconstruction();
|
||||
redrawWeights((int)WeightsSlider->getValue());
|
||||
//[/UserButtonCode_trainButton]
|
||||
}
|
||||
else if (buttonThatWasClicked == addButton)
|
||||
{
|
||||
//[UserButtonCode_addButton] -- add your button handler code here..
|
||||
Draw2->setData(Draw->getData());
|
||||
m_layers.add(&Draw->getData(), m_vNumX*m_vNumY);
|
||||
DrawReconstruction->setData(DrawTraining->getData());
|
||||
m_layers.add(&DrawTraining->getData(), m_vNumX*m_vNumY);
|
||||
patterSlider->setRange (0, m_layers.getSize()-1, 1);
|
||||
//[/UserButtonCode_addButton]
|
||||
}
|
||||
else if (buttonThatWasClicked == reconstructButton)
|
||||
{
|
||||
//[UserButtonCode_reconstructButton] -- add your button handler code here..
|
||||
Draw2->setData(m_pRbm->toVisible(m_pRbm->toHidden(Draw->getData())));
|
||||
DrawHidden->setData(m_pRbm->toHidden(Draw->getData()));
|
||||
redrawReconstruction();
|
||||
//[/UserButtonCode_reconstructButton]
|
||||
}
|
||||
else if (buttonThatWasClicked == ShakeButton)
|
||||
{
|
||||
//[UserButtonCode_ShakeButton] -- add your button handler code here..
|
||||
m_weights.shuffle(0.01);
|
||||
redrawReconstruction();
|
||||
redrawWeights((int)WeightsSlider->getValue());
|
||||
//[/UserButtonCode_ShakeButton]
|
||||
}
|
||||
else if (buttonThatWasClicked == testButton)
|
||||
{
|
||||
//[UserButtonCode_testButton] -- add your button handler code here..
|
||||
Draw->setData(Draw2->getData());
|
||||
DrawTraining->setData(DrawReconstruction->getData());
|
||||
redrawReconstruction();
|
||||
//[/UserButtonCode_testButton]
|
||||
}
|
||||
else if (buttonThatWasClicked == createButton)
|
||||
@@ -367,9 +454,6 @@ void MainComponent::buttonClicked (Button* buttonThatWasClicked)
|
||||
m_vNumX = m_vNumX_next;
|
||||
m_vNumY = m_vNumY_next;
|
||||
m_hNum = m_hNum_next;
|
||||
numVisibleLabel->setText(String(m_vNumX), dontSendNotification );
|
||||
numVisibleYLabel->setText(String(m_vNumY), dontSendNotification );
|
||||
numHiddenLabel->setText(String(m_hNum), dontSendNotification );
|
||||
m_weights.setUnits(m_vNumX*m_vNumY, m_hNum);
|
||||
create();
|
||||
//[/UserButtonCode_createButton]
|
||||
@@ -378,6 +462,8 @@ void MainComponent::buttonClicked (Button* buttonThatWasClicked)
|
||||
{
|
||||
//[UserButtonCode_loadButton] -- add your button handler code here..
|
||||
load();
|
||||
redrawReconstruction();
|
||||
redrawWeights((int)WeightsSlider->getValue());
|
||||
//[/UserButtonCode_loadButton]
|
||||
}
|
||||
else if (buttonThatWasClicked == saveButton)
|
||||
@@ -391,7 +477,8 @@ void MainComponent::buttonClicked (Button* buttonThatWasClicked)
|
||||
//[UserButtonCode_loadTrainingButton] -- add your button handler code here..
|
||||
m_layers.clear();
|
||||
m_layers.load((String(getBaseDir() + String(".trainingStates.dat"))).toUTF8());
|
||||
//[/UserButtonCode_loadTrainingButton]
|
||||
redrawReconstruction();
|
||||
//[/UserButtonCode_loadTrainingButton]
|
||||
}
|
||||
else if (buttonThatWasClicked == saveTrainingButton)
|
||||
{
|
||||
@@ -414,45 +501,56 @@ void MainComponent::buttonClicked (Button* buttonThatWasClicked)
|
||||
else if (buttonThatWasClicked == reconstructEquButton)
|
||||
{
|
||||
//[UserButtonCode_reconstructEquButton] -- add your button handler code here..
|
||||
// Draw2->setData(m_pRbm->expectVisible(Draw->getData(), 100));
|
||||
|
||||
uint32_t i;
|
||||
VectorXd V, H;
|
||||
|
||||
V = Draw->getData();
|
||||
V = DrawTraining->getData();
|
||||
for (i=0; i < 100; i++)
|
||||
{
|
||||
H = m_pRbm->toHidden(V);
|
||||
DrawHidden->setData(H);
|
||||
V = m_pRbm->toVisible(H);
|
||||
Draw2->setData(V);
|
||||
DrawReconstruction->setData(V);
|
||||
}
|
||||
//[/UserButtonCode_reconstructEquButton]
|
||||
}
|
||||
else if (buttonThatWasClicked == rbmUseExpectationsToggleButton)
|
||||
{
|
||||
//[UserButtonCode_rbmUseExpectationsToggleButton] -- add your button handler code here..
|
||||
m_rbmUseExpectations = buttonThatWasClicked->getToggleState();
|
||||
m_pRbm->setUseExpectations(buttonThatWasClicked->getToggleState());
|
||||
//[/UserButtonCode_rbmUseExpectationsToggleButton]
|
||||
}
|
||||
else if (buttonThatWasClicked == rbmDoRaoBlackwellToggleButton)
|
||||
{
|
||||
//[UserButtonCode_rbmDoRaoBlackwellToggleButton] -- add your button handler code here..
|
||||
m_rbmDoRaoBlackwell = buttonThatWasClicked->getToggleState();
|
||||
m_pRbm->setDoRaoBlackwell(buttonThatWasClicked->getToggleState());
|
||||
//[/UserButtonCode_rbmDoRaoBlackwellToggleButton]
|
||||
}
|
||||
else if (buttonThatWasClicked == rbmDoRobbinsMonroToggleButton)
|
||||
{
|
||||
//[UserButtonCode_rbmDoRobbinsMonroToggleButton] -- add your button handler code here..
|
||||
m_rbmDoRobbinsMonro = buttonThatWasClicked->getToggleState();
|
||||
m_pRbm->setDoRobbinsMonro(buttonThatWasClicked->getToggleState());
|
||||
//[/UserButtonCode_rbmDoRobbinsMonroToggleButton]
|
||||
}
|
||||
else if (buttonThatWasClicked == rbmReduceVarianceToggleButton)
|
||||
{
|
||||
//[UserButtonCode_rbmReduceVarianceToggleButton] -- add your button handler code here..
|
||||
m_rbmReduceEstimatorVariance = buttonThatWasClicked->getToggleState();
|
||||
m_pRbm->setUseProbsForHiddenReconstruction(buttonThatWasClicked->getToggleState());
|
||||
//[/UserButtonCode_rbmReduceVarianceToggleButton]
|
||||
}
|
||||
else if (buttonThatWasClicked == rbmUseVisibleGaussianToggleButton)
|
||||
{
|
||||
//[UserButtonCode_rbmUseVisibleGaussianToggleButton] -- add your button handler code here..
|
||||
m_pRbm->setUseVisibleGaussian(buttonThatWasClicked->getToggleState());
|
||||
redrawReconstruction();
|
||||
//[/UserButtonCode_rbmUseVisibleGaussianToggleButton]
|
||||
}
|
||||
else if (buttonThatWasClicked == rbmDoSparseToggleButton)
|
||||
{
|
||||
//[UserButtonCode_rbmDoSparseToggleButton] -- add your button handler code here..
|
||||
m_pRbm->setDoSparse(buttonThatWasClicked->getToggleState());
|
||||
//[/UserButtonCode_rbmDoSparseToggleButton]
|
||||
}
|
||||
|
||||
//[UserbuttonClicked_Post]
|
||||
//[/UserbuttonClicked_Post]
|
||||
@@ -469,33 +567,14 @@ void MainComponent::sliderValueChanged (Slider* sliderThatWasMoved)
|
||||
if (m_layers.getSize() > 0)
|
||||
{
|
||||
VisibleLayer &p = (VisibleLayer&)m_layers.getAt((int)sliderThatWasMoved->getValue());
|
||||
Draw2->setData(p.states());
|
||||
DrawReconstruction->setData(p.states());
|
||||
}
|
||||
//[/UserSliderCode_patterSlider]
|
||||
}
|
||||
else if (sliderThatWasMoved == WeightsSlider)
|
||||
{
|
||||
//[UserSliderCode_WeightsSlider] -- add your slider handling code here..
|
||||
VectorXd w = m_weights.weights().col((int)sliderThatWasMoved->getValue());
|
||||
VectorXd temp = w;
|
||||
double min = +1E12;
|
||||
double max = -1E12;
|
||||
|
||||
for (int i=0; i < m_vNumX*m_vNumY; i++)
|
||||
{
|
||||
min = std::min<double>(min, (double)temp[i]);
|
||||
max = std::max<double>(max, (double)temp[i]);
|
||||
}
|
||||
for (int i=0; i < m_vNumX*m_vNumY; i++)
|
||||
{
|
||||
temp[i] -= min;
|
||||
}
|
||||
for (int i=0; i < m_vNumX*m_vNumY; i++)
|
||||
{
|
||||
temp[i] /= (max-min);
|
||||
}
|
||||
|
||||
DrawWeights->setData(temp);
|
||||
redrawWeights((int)sliderThatWasMoved->getValue());
|
||||
//[/UserSliderCode_WeightsSlider]
|
||||
}
|
||||
else if (sliderThatWasMoved == numGibbsSlider)
|
||||
@@ -547,6 +626,32 @@ void MainComponent::labelTextChanged (Label* labelThatHasChanged)
|
||||
m_vNumY_next = labelThatHasChanged->getText().getIntValue();
|
||||
//[/UserLabelCode_numVisibleYLabel]
|
||||
}
|
||||
else if (labelThatHasChanged == lambdaLabel)
|
||||
{
|
||||
//[UserLabelCode_lambdaLabel] -- add your label text handling code here..
|
||||
m_pRbm->setLambda(labelThatHasChanged->getText().getFloatValue());
|
||||
redrawReconstruction();
|
||||
//[/UserLabelCode_lambdaLabel]
|
||||
}
|
||||
else if (labelThatHasChanged == sigmaLabel)
|
||||
{
|
||||
//[UserLabelCode_sigmaLabel] -- add your label text handling code here..
|
||||
m_pRbm->setSigma(labelThatHasChanged->getText().getFloatValue());
|
||||
redrawReconstruction();
|
||||
//[/UserLabelCode_sigmaLabel]
|
||||
}
|
||||
else if (labelThatHasChanged == sparsityLabel)
|
||||
{
|
||||
//[UserLabelCode_sparsityLabel] -- add your label text handling code here..
|
||||
m_pRbm->setSparsity(labelThatHasChanged->getText().getFloatValue());
|
||||
//[/UserLabelCode_sparsityLabel]
|
||||
}
|
||||
else if (labelThatHasChanged == sigmaDecayLabel)
|
||||
{
|
||||
//[UserLabelCode_sigmaDecayLabel] -- add your label text handling code here..
|
||||
m_pRbm->setSigmaDecay(labelThatHasChanged->getText().getFloatValue());
|
||||
//[/UserLabelCode_sigmaDecayLabel]
|
||||
}
|
||||
|
||||
//[UserlabelTextChanged_Post]
|
||||
//[/UserlabelTextChanged_Post]
|
||||
@@ -571,22 +676,37 @@ void MainComponent::save ()
|
||||
|
||||
void MainComponent::create()
|
||||
{
|
||||
Draw = nullptr;
|
||||
Draw2 = nullptr;
|
||||
DrawTraining = nullptr;
|
||||
DrawReconstruction = nullptr;
|
||||
DrawWeights = nullptr;
|
||||
DrawHidden = nullptr;
|
||||
m_pRbm = nullptr;
|
||||
addAndMakeVisible (Draw = new DrawComponent (m_vNumX, m_vNumY));
|
||||
Draw->setListener(this);
|
||||
addAndMakeVisible (Draw2 = new DrawComponent (m_vNumX, m_vNumY));
|
||||
|
||||
WeightsSlider->setRange(0, m_hNum-1, 1);
|
||||
|
||||
addAndMakeVisible (DrawTraining = new DrawComponent (m_vNumX, m_vNumY));
|
||||
DrawTraining->setListener(this);
|
||||
addAndMakeVisible (DrawReconstruction = new DrawComponent (m_vNumX, m_vNumY));
|
||||
addAndMakeVisible (DrawWeights = new DrawComponent (m_vNumX, m_vNumY));
|
||||
addAndMakeVisible (DrawHidden = new DrawComponent (m_hNum, 1));
|
||||
DrawHidden->setListener(this);
|
||||
numVisibleLabel->setText(String(m_vNumX), dontSendNotification );
|
||||
numVisibleYLabel->setText(String(m_vNumY), dontSendNotification );
|
||||
numHiddenLabel->setText(String(m_hNum), dontSendNotification );
|
||||
|
||||
m_pRbm = new Rbm(m_weights, this);
|
||||
WeightsSlider->setRange(0, m_hNum-1, 1);
|
||||
m_pRbm->setUseExpectations(rbmUseExpectationsToggleButton->getToggleState());
|
||||
m_pRbm->setDoRaoBlackwell(rbmDoRaoBlackwellToggleButton->getToggleState());
|
||||
m_pRbm->setDoRobbinsMonro(rbmDoRobbinsMonroToggleButton->getToggleState());
|
||||
m_pRbm->setUseProbsForHiddenReconstruction(rbmReduceVarianceToggleButton->getToggleState());
|
||||
m_pRbm->setUseVisibleGaussian(rbmUseVisibleGaussianToggleButton->getToggleState());
|
||||
m_pRbm->setDoSparse(rbmDoSparseToggleButton->getToggleState());
|
||||
|
||||
m_pRbm->setLambda(lambdaLabel->getText().getFloatValue());
|
||||
m_pRbm->setSigma(sigmaLabel->getText().getFloatValue());
|
||||
m_pRbm->setSigmaDecay(sigmaDecayLabel->getText().getFloatValue());
|
||||
m_pRbm->setSparsity(sparsityLabel->getText().getFloatValue());
|
||||
|
||||
resized();
|
||||
}
|
||||
|
||||
@@ -617,15 +737,45 @@ void MainComponent::onDraw(DrawComponent &obj)
|
||||
{
|
||||
if (&obj == DrawHidden)
|
||||
{
|
||||
Draw2->setData(m_pRbm->toVisible(obj.getData()));
|
||||
DrawReconstruction->setData(m_pRbm->toVisible(obj.getData()));
|
||||
}
|
||||
if (&obj == Draw)
|
||||
if (&obj == DrawTraining)
|
||||
{
|
||||
Draw2->setData(m_pRbm->toVisible(m_pRbm->toHidden(obj.getData())));
|
||||
DrawReconstruction->setData(m_pRbm->toVisible(m_pRbm->toHidden(obj.getData())));
|
||||
DrawHidden->setData(m_pRbm->toHidden(obj.getData()));
|
||||
}
|
||||
}
|
||||
|
||||
void MainComponent::redrawReconstruction()
|
||||
{
|
||||
DrawHidden->setData(m_pRbm->toHidden(DrawTraining->getData()));
|
||||
DrawReconstruction->setData(m_pRbm->toVisible(DrawHidden->getData()));
|
||||
}
|
||||
|
||||
void MainComponent::redrawWeights(int index)
|
||||
{
|
||||
VectorXd w = m_weights.weights().col(index);
|
||||
VectorXd temp = w;
|
||||
double min = +1E12;
|
||||
double max = -1E12;
|
||||
|
||||
for (int i=0; i < m_vNumX*m_vNumY; i++)
|
||||
{
|
||||
min = std::min<double>(min, (double)temp[i]);
|
||||
max = std::max<double>(max, (double)temp[i]);
|
||||
}
|
||||
for (int i=0; i < m_vNumX*m_vNumY; i++)
|
||||
{
|
||||
temp[i] -= min;
|
||||
}
|
||||
for (int i=0; i < m_vNumX*m_vNumY; i++)
|
||||
{
|
||||
temp[i] /= (max-min);
|
||||
}
|
||||
|
||||
DrawWeights->setData(temp);
|
||||
}
|
||||
|
||||
//[/MiscUserCode]
|
||||
|
||||
|
||||
@@ -640,69 +790,82 @@ BEGIN_JUCER_METADATA
|
||||
|
||||
<JUCER_COMPONENT documentType="Component" className="MainComponent" componentName=""
|
||||
parentClasses="public Component, public LayerArrayListener<VisibleLayer>, public RbmListener, public DrawListener"
|
||||
constructorParams="" variableInitialisers="m_layers(this), m_pRbm(nullptr) Draw(nullptr), Draw2(nullptr), DrawWeights(nullptr), DrawHidden(nullptr)"
|
||||
constructorParams="" variableInitialisers="m_layers(this), m_pRbm(nullptr) DrawTraining(nullptr), DrawReconstruction(nullptr), DrawWeights(nullptr), DrawHidden(nullptr)"
|
||||
snapPixels="8" snapActive="1" snapShown="1" overlayOpacity="0.330"
|
||||
fixedSize="1" initialWidth="600" initialHeight="400">
|
||||
<BACKGROUND backgroundColour="ffffffff"/>
|
||||
fixedSize="1" initialWidth="800" initialHeight="600">
|
||||
<BACKGROUND backgroundColour="ffffffff">
|
||||
<TEXT pos="32 306 80 14" fill="solid: ff000000" hasStroke="0" text="Sigma"
|
||||
fontname="Default font" fontsize="15" bold="0" italic="0" justification="36"/>
|
||||
<TEXT pos="120 306 80 14" fill="solid: ff000000" hasStroke="0" text="Lambda"
|
||||
fontname="Default font" fontsize="15" bold="0" italic="0" justification="36"/>
|
||||
<TEXT pos="32 354 80 14" fill="solid: ff000000" hasStroke="0" text="Num. epochs"
|
||||
fontname="Default font" fontsize="15" bold="0" italic="0" justification="36"/>
|
||||
<TEXT pos="120 354 80 14" fill="solid: ff000000" hasStroke="0" text="Alpha"
|
||||
fontname="Default font" fontsize="15" bold="0" italic="0" justification="36"/>
|
||||
<TEXT pos="208 306 80 14" fill="solid: ff000000" hasStroke="0" text="Sparsity"
|
||||
fontname="Default font" fontsize="15" bold="0" italic="0" justification="36"/>
|
||||
<TEXT pos="296 306 96 14" fill="solid: ff000000" hasStroke="0" text="Sigma decay"
|
||||
fontname="Default font" fontsize="15" bold="0" italic="0" justification="36"/>
|
||||
</BACKGROUND>
|
||||
<TEXTBUTTON name="Train button" id="7909d74b5522987c" memberName="trainButton"
|
||||
virtualName="" explicitFocusOrder="0" pos="120 312 72 24" buttonText="Train"
|
||||
virtualName="" explicitFocusOrder="0" pos="120 408 72 24" buttonText="Train"
|
||||
connectedEdges="0" needsCallback="1" radioGroupId="0"/>
|
||||
<TEXTBUTTON name="Add button" id="4609f7b526ec1aef" memberName="addButton"
|
||||
virtualName="" explicitFocusOrder="0" pos="24 160 72 24" buttonText="Add"
|
||||
connectedEdges="0" needsCallback="1" radioGroupId="0"/>
|
||||
<SLIDER name="Pattern slider" id="c3e0a2c816db81d1" memberName="patterSlider"
|
||||
virtualName="" explicitFocusOrder="0" pos="224 312 184 24" min="0"
|
||||
virtualName="" explicitFocusOrder="0" pos="224 408 184 24" min="0"
|
||||
max="0" int="1" style="LinearHorizontal" textBoxPos="TextBoxLeft"
|
||||
textBoxEditable="1" textBoxWidth="80" textBoxHeight="20" skewFactor="1"/>
|
||||
<TEXTBUTTON name="Reconstruct button" id="c1901d121a5819d6" memberName="reconstructButton"
|
||||
virtualName="" explicitFocusOrder="0" pos="24 312 72 24" buttonText="Reconstruct"
|
||||
virtualName="" explicitFocusOrder="0" pos="24 408 72 24" buttonText="Reconstruct"
|
||||
connectedEdges="0" needsCallback="1" radioGroupId="0"/>
|
||||
<TEXTBUTTON name="Shake button" id="7fa4964a9a9ed199" memberName="ShakeButton"
|
||||
virtualName="" explicitFocusOrder="0" pos="120 352 72 24" buttonText="Shake"
|
||||
virtualName="" explicitFocusOrder="0" pos="120 448 72 24" buttonText="Shake"
|
||||
connectedEdges="0" needsCallback="1" radioGroupId="0"/>
|
||||
<SLIDER name="Weights slider" id="699075a1fc01458a" memberName="WeightsSlider"
|
||||
virtualName="" explicitFocusOrder="0" pos="224 352 184 24" min="0"
|
||||
virtualName="" explicitFocusOrder="0" pos="224 448 184 24" min="0"
|
||||
max="0" int="1" style="LinearHorizontal" textBoxPos="TextBoxLeft"
|
||||
textBoxEditable="1" textBoxWidth="80" textBoxHeight="20" skewFactor="1"/>
|
||||
<LABEL name="Num Epochs label" id="b23ae372ee931474" memberName="numEpochslabel"
|
||||
virtualName="" explicitFocusOrder="0" pos="24 280 72 24" edTextCol="ff000000"
|
||||
edBkgCol="0" labelText="99999" editableSingleClick="1" editableDoubleClick="1"
|
||||
virtualName="" explicitFocusOrder="0" pos="32 368 72 24" edTextCol="ff000000"
|
||||
edBkgCol="0" labelText="100" editableSingleClick="1" editableDoubleClick="1"
|
||||
focusDiscardsChanges="0" fontname="Default font" fontsize="15"
|
||||
bold="0" italic="0" justification="36"/>
|
||||
<LABEL name="Learning Rate label" id="49611a27914e910d" memberName="learningRateLabel"
|
||||
virtualName="" explicitFocusOrder="0" pos="120 280 72 24" edTextCol="ff000000"
|
||||
edBkgCol="0" labelText="0.001" editableSingleClick="1" editableDoubleClick="1"
|
||||
virtualName="" explicitFocusOrder="0" pos="120 368 72 24" edTextCol="ff000000"
|
||||
edBkgCol="0" labelText="0.03" editableSingleClick="1" editableDoubleClick="1"
|
||||
focusDiscardsChanges="0" fontname="Default font" fontsize="15"
|
||||
bold="0" italic="0" justification="36"/>
|
||||
<TEXTBUTTON name="Test button" id="a1e6fed732ae7ee1" memberName="testButton"
|
||||
virtualName="" explicitFocusOrder="0" pos="120 160 72 24" buttonText="Test"
|
||||
connectedEdges="0" needsCallback="1" radioGroupId="0"/>
|
||||
<LABEL name="Num Visible label" id="60acd702770b77dd" memberName="numVisibleLabel"
|
||||
virtualName="" explicitFocusOrder="0" pos="440 256 72 24" edTextCol="ff000000"
|
||||
virtualName="" explicitFocusOrder="0" pos="456 328 72 24" edTextCol="ff000000"
|
||||
edBkgCol="0" labelText="99999" editableSingleClick="1" editableDoubleClick="1"
|
||||
focusDiscardsChanges="0" fontname="Default font" fontsize="15"
|
||||
bold="0" italic="0" justification="36"/>
|
||||
<LABEL name="Num Hidden label" id="8a56c0419bd3ce86" memberName="numHiddenLabel"
|
||||
virtualName="" explicitFocusOrder="0" pos="488 288 72 24" edTextCol="ff000000"
|
||||
virtualName="" explicitFocusOrder="0" pos="504 360 72 24" edTextCol="ff000000"
|
||||
edBkgCol="0" labelText="99999" editableSingleClick="1" editableDoubleClick="1"
|
||||
focusDiscardsChanges="0" fontname="Default font" fontsize="15"
|
||||
bold="0" italic="0" justification="36"/>
|
||||
<TEXTBUTTON name="Create button" id="6c71593a581844eb" memberName="createButton"
|
||||
virtualName="" explicitFocusOrder="0" pos="488 320 72 24" buttonText="Create"
|
||||
virtualName="" explicitFocusOrder="0" pos="504 392 72 24" buttonText="Create"
|
||||
connectedEdges="0" needsCallback="1" radioGroupId="0"/>
|
||||
<LABEL name="Project Name label" id="b4e855167abdac6b" memberName="projectNameLabel"
|
||||
virtualName="" explicitFocusOrder="0" pos="472 224 96 24" edTextCol="ff000000"
|
||||
edBkgCol="0" labelText="ProjectName" editableSingleClick="1"
|
||||
editableDoubleClick="1" focusDiscardsChanges="0" fontname="Default font"
|
||||
fontsize="15" bold="0" italic="0" justification="36"/>
|
||||
virtualName="" explicitFocusOrder="0" pos="488 296 96 24" edTextCol="ff000000"
|
||||
edBkgCol="0" labelText="TestPrj" editableSingleClick="1" editableDoubleClick="1"
|
||||
focusDiscardsChanges="0" fontname="Default font" fontsize="15"
|
||||
bold="0" italic="0" justification="36"/>
|
||||
<TEXTBUTTON name="Load button" id="4e606c77b12e7d11" memberName="loadButton"
|
||||
virtualName="" explicitFocusOrder="0" pos="440 192 72 24" buttonText="Load"
|
||||
virtualName="" explicitFocusOrder="0" pos="456 264 72 24" buttonText="Load"
|
||||
connectedEdges="0" needsCallback="1" radioGroupId="0"/>
|
||||
<TEXTBUTTON name="Save button" id="c435e774a51e39bf" memberName="saveButton"
|
||||
virtualName="" explicitFocusOrder="0" pos="520 192 72 24" buttonText="Save"
|
||||
virtualName="" explicitFocusOrder="0" pos="536 264 72 24" buttonText="Save"
|
||||
connectedEdges="0" needsCallback="1" radioGroupId="0"/>
|
||||
<LABEL name="Num Visible Y label" id="101a4f77ca2445ba" memberName="numVisibleYLabel"
|
||||
virtualName="" explicitFocusOrder="0" pos="512 256 72 24" edTextCol="ff000000"
|
||||
virtualName="" explicitFocusOrder="0" pos="528 328 72 24" edTextCol="ff000000"
|
||||
edBkgCol="0" labelText="99999" editableSingleClick="1" editableDoubleClick="1"
|
||||
focusDiscardsChanges="0" fontname="Default font" fontsize="15"
|
||||
bold="0" italic="0" justification="36"/>
|
||||
@@ -719,11 +882,11 @@ BEGIN_JUCER_METADATA
|
||||
virtualName="" explicitFocusOrder="0" pos="440 88 72 24" buttonText="Remove T"
|
||||
connectedEdges="0" needsCallback="1" radioGroupId="0"/>
|
||||
<SLIDER name="Num. Gibbs slider" id="fdd9d5ca4e05e18c" memberName="numGibbsSlider"
|
||||
virtualName="" explicitFocusOrder="0" pos="224 272 184 24" min="1"
|
||||
virtualName="" explicitFocusOrder="0" pos="224 368 184 24" min="1"
|
||||
max="10" int="1" style="LinearHorizontal" textBoxPos="TextBoxLeft"
|
||||
textBoxEditable="1" textBoxWidth="80" textBoxHeight="20" skewFactor="1"/>
|
||||
<TEXTBUTTON name="Reconstruct Equilibrium button" id="208a587f5556207" memberName="reconstructEquButton"
|
||||
virtualName="" explicitFocusOrder="0" pos="24 352 72 24" buttonText="Reconst Equ."
|
||||
virtualName="" explicitFocusOrder="0" pos="24 448 72 24" buttonText="Reconst Equ."
|
||||
connectedEdges="0" needsCallback="1" radioGroupId="0"/>
|
||||
<TOGGLEBUTTON name="rbmUseExpectations toggle button" id="62884e37cd027719"
|
||||
memberName="rbmUseExpectationsToggleButton" virtualName="" explicitFocusOrder="0"
|
||||
@@ -741,6 +904,33 @@ BEGIN_JUCER_METADATA
|
||||
memberName="rbmReduceVarianceToggleButton" virtualName="" explicitFocusOrder="0"
|
||||
pos="168 200 128 24" buttonText="Reduce Variance" connectedEdges="0"
|
||||
needsCallback="1" radioGroupId="0" state="0"/>
|
||||
<LABEL name="Lambda label" id="c51a5dfb587390b4" memberName="lambdaLabel"
|
||||
virtualName="" explicitFocusOrder="0" pos="120 320 72 24" edTextCol="ff000000"
|
||||
edBkgCol="0" labelText="1.0" editableSingleClick="1" editableDoubleClick="1"
|
||||
focusDiscardsChanges="0" fontname="Default font" fontsize="15"
|
||||
bold="0" italic="0" justification="36"/>
|
||||
<LABEL name="Sigma label" id="68d7dad32ed357f8" memberName="sigmaLabel"
|
||||
virtualName="" explicitFocusOrder="0" pos="32 320 72 24" edTextCol="ff000000"
|
||||
edBkgCol="0" labelText="0.5" editableSingleClick="1" editableDoubleClick="1"
|
||||
focusDiscardsChanges="0" fontname="Default font" fontsize="15"
|
||||
bold="0" italic="0" justification="36"/>
|
||||
<TOGGLEBUTTON name="rbmUseVisibleGaussian toggle button" id="c89b32a4deaa7f19"
|
||||
memberName="rbmUseVisibleGaussianToggleButton" virtualName=""
|
||||
explicitFocusOrder="0" pos="168 264 160 24" buttonText="Use gaussian visible"
|
||||
connectedEdges="0" needsCallback="1" radioGroupId="0" state="0"/>
|
||||
<TOGGLEBUTTON name="rbmDoSparse toggle button" id="ed3f2602ab35b5f2" memberName="rbmDoSparseToggleButton"
|
||||
virtualName="" explicitFocusOrder="0" pos="24 264 128 24" buttonText="Do sparse"
|
||||
connectedEdges="0" needsCallback="1" radioGroupId="0" state="0"/>
|
||||
<LABEL name="Sparsity label" id="f4efe44dc0ca4894" memberName="sparsityLabel"
|
||||
virtualName="" explicitFocusOrder="0" pos="208 320 72 24" edTextCol="ff000000"
|
||||
edBkgCol="0" labelText="0.05" editableSingleClick="1" editableDoubleClick="1"
|
||||
focusDiscardsChanges="0" fontname="Default font" fontsize="15"
|
||||
bold="0" italic="0" justification="36"/>
|
||||
<LABEL name="SigmaDecay label" id="d5f2f5fffdafd926" memberName="sigmaDecayLabel"
|
||||
virtualName="" explicitFocusOrder="0" pos="304 320 72 24" edTextCol="ff000000"
|
||||
edBkgCol="0" labelText="1.0" editableSingleClick="1" editableDoubleClick="1"
|
||||
focusDiscardsChanges="0" fontname="Default font" fontsize="15"
|
||||
bold="0" italic="0" justification="36"/>
|
||||
</JUCER_COMPONENT>
|
||||
|
||||
END_JUCER_METADATA
|
||||
|
||||
Reference in New Issue
Block a user