[RBM]
- moved sigma and mean from WEIGHTS to RBM - use Gibbs slider also for reconstruction draw git-svn-id: http://moon:8086/svn/software/trunk/projects/RBM@287 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
+33
-38
@@ -74,7 +74,7 @@ MainComponent::MainComponent ()
|
||||
WeightsSlider->addListener (this);
|
||||
|
||||
addAndMakeVisible (numEpochslabel = new Label ("Num Epochs label",
|
||||
TRANS("100")));
|
||||
TRANS("1000")));
|
||||
numEpochslabel->setFont (Font (15.00f, Font::plain));
|
||||
numEpochslabel->setJustificationType (Justification::centred);
|
||||
numEpochslabel->setEditable (true, true, false);
|
||||
@@ -118,7 +118,7 @@ MainComponent::MainComponent ()
|
||||
createButton->addListener (this);
|
||||
|
||||
addAndMakeVisible (projectNameLabel = new Label ("Project Name label",
|
||||
TRANS("TestPrj")));
|
||||
TRANS("test")));
|
||||
projectNameLabel->setFont (Font (15.00f, Font::plain));
|
||||
projectNameLabel->setJustificationType (Justification::centred);
|
||||
projectNameLabel->setEditable (true, true, false);
|
||||
@@ -482,14 +482,14 @@ void MainComponent::buttonClicked (Button* buttonThatWasClicked)
|
||||
else if (buttonThatWasClicked == reconstructButton)
|
||||
{
|
||||
//[UserButtonCode_reconstructButton] -- add your button handler code here..
|
||||
redrawReconstruction();
|
||||
redrawReconstruction(numGibbsSlider->getValue());
|
||||
//[/UserButtonCode_reconstructButton]
|
||||
}
|
||||
else if (buttonThatWasClicked == ShakeButton)
|
||||
{
|
||||
//[UserButtonCode_ShakeButton] -- add your button handler code here..
|
||||
m_weights->shuffle(weightInitLabel->getText().getFloatValue());
|
||||
redrawReconstruction();
|
||||
redrawReconstruction(numGibbsSlider->getValue());
|
||||
redrawWeights((int)WeightsSlider->getValue());
|
||||
//[/UserButtonCode_ShakeButton]
|
||||
}
|
||||
@@ -497,7 +497,7 @@ void MainComponent::buttonClicked (Button* buttonThatWasClicked)
|
||||
{
|
||||
//[UserButtonCode_testButton] -- add your button handler code here..
|
||||
DrawTraining->setData(DrawReconstruction->getData());
|
||||
redrawReconstruction();
|
||||
redrawReconstruction(numGibbsSlider->getValue());
|
||||
//[/UserButtonCode_testButton]
|
||||
}
|
||||
else if (buttonThatWasClicked == createButton)
|
||||
@@ -546,17 +546,7 @@ void MainComponent::buttonClicked (Button* buttonThatWasClicked)
|
||||
else if (buttonThatWasClicked == reconstructEquButton)
|
||||
{
|
||||
//[UserButtonCode_reconstructEquButton] -- add your button handler code here..
|
||||
uint32_t i;
|
||||
VectorXd V, H;
|
||||
|
||||
V = DrawTraining->getData();
|
||||
for (i=0; i < 100; i++)
|
||||
{
|
||||
H = m_pRbm->toHidden(V);
|
||||
DrawHidden->setData(H);
|
||||
V = m_pRbm->toVisible(H);
|
||||
DrawReconstruction->setData(V);
|
||||
}
|
||||
redrawReconstruction(100);
|
||||
//[/UserButtonCode_reconstructEquButton]
|
||||
}
|
||||
else if (buttonThatWasClicked == rbmDoRaoBlackwellToggleButton)
|
||||
@@ -575,7 +565,7 @@ void MainComponent::buttonClicked (Button* buttonThatWasClicked)
|
||||
{
|
||||
//[UserButtonCode_rbmUseVisibleGaussianToggleButton] -- add your button handler code here..
|
||||
m_pRbm->setUseVisibleGaussian(buttonThatWasClicked->getToggleState());
|
||||
redrawReconstruction();
|
||||
redrawReconstruction(numGibbsSlider->getValue());
|
||||
//[/UserButtonCode_rbmUseVisibleGaussianToggleButton]
|
||||
}
|
||||
else if (buttonThatWasClicked == rbmDoSparseToggleButton)
|
||||
@@ -588,6 +578,10 @@ void MainComponent::buttonClicked (Button* buttonThatWasClicked)
|
||||
{
|
||||
//[UserButtonCode_rbmLearnVarianceButton] -- add your button handler code here..
|
||||
m_pRbm->setDoLearnVariance(buttonThatWasClicked->getToggleState());
|
||||
if (!buttonThatWasClicked->getToggleState())
|
||||
{
|
||||
m_pRbm->setSigma(sigmaLabel->getText().getFloatValue());
|
||||
}
|
||||
//[/UserButtonCode_rbmLearnVarianceButton]
|
||||
}
|
||||
else if (buttonThatWasClicked == rbmNormalizeDataToggleButton)
|
||||
@@ -614,7 +608,7 @@ void MainComponent::sliderValueChanged (Slider* sliderThatWasMoved)
|
||||
RowVectorXd t = m_layers.getAt((int)sliderThatWasMoved->getValue());
|
||||
|
||||
DrawTraining->setData(t);
|
||||
redrawReconstruction();
|
||||
redrawReconstruction(numGibbsSlider->getValue());
|
||||
}
|
||||
//[/UserSliderCode_patterSlider]
|
||||
}
|
||||
@@ -628,6 +622,7 @@ void MainComponent::sliderValueChanged (Slider* sliderThatWasMoved)
|
||||
{
|
||||
//[UserSliderCode_numGibbsSlider] -- add your slider handling code here..
|
||||
m_pRbm->setNumGibbs((uint32_t)sliderThatWasMoved->getValue());
|
||||
redrawReconstruction(sliderThatWasMoved->getValue());
|
||||
//[/UserSliderCode_numGibbsSlider]
|
||||
}
|
||||
else if (sliderThatWasMoved == m_progressBarSlider)
|
||||
@@ -680,14 +675,16 @@ void MainComponent::labelTextChanged (Label* labelThatHasChanged)
|
||||
{
|
||||
//[UserLabelCode_lambdaLabel] -- add your label text handling code here..
|
||||
m_pRbm->setLambda(labelThatHasChanged->getText().getFloatValue());
|
||||
redrawReconstruction();
|
||||
redrawReconstruction(numGibbsSlider->getValue());
|
||||
//[/UserLabelCode_lambdaLabel]
|
||||
}
|
||||
else if (labelThatHasChanged == sigmaLabel)
|
||||
{
|
||||
//[UserLabelCode_sigmaLabel] -- add your label text handling code here..
|
||||
m_pRbm->setSigma(labelThatHasChanged->getText().getFloatValue());
|
||||
redrawReconstruction();
|
||||
DrawVars->setData(m_pRbm->getSigma());
|
||||
redrawReconstruction(numGibbsSlider->getValue());
|
||||
|
||||
//[/UserLabelCode_sigmaLabel]
|
||||
}
|
||||
else if (labelThatHasChanged == sparsityLabel)
|
||||
@@ -844,7 +841,7 @@ void MainComponent::create(const char *pFilename)
|
||||
|
||||
resized();
|
||||
|
||||
redrawReconstruction();
|
||||
redrawReconstruction(numGibbsSlider->getValue());
|
||||
redrawWeights((int)WeightsSlider->getValue());
|
||||
}
|
||||
|
||||
@@ -868,7 +865,7 @@ void MainComponent::onChanged(const LayerArray &obj)
|
||||
void MainComponent::onEpochTrained(const Rbm &obj)
|
||||
{
|
||||
// mylog("Training %f %%\n", obj.getProgress()*100);
|
||||
redrawReconstruction();
|
||||
redrawReconstruction(numGibbsSlider->getValue());
|
||||
redrawWeights((int)WeightsSlider->getValue());
|
||||
m_progressBarSlider->setValue((int)(100*obj.getProgress()), dontSendNotification);
|
||||
}
|
||||
@@ -881,25 +878,23 @@ void MainComponent::onDraw(DrawComponent &obj)
|
||||
}
|
||||
if (&obj == DrawTraining)
|
||||
{
|
||||
redrawReconstruction();
|
||||
redrawReconstruction(numGibbsSlider->getValue());
|
||||
}
|
||||
}
|
||||
|
||||
void MainComponent::redrawReconstruction()
|
||||
void MainComponent::redrawReconstruction(uint32_t numIter)
|
||||
{
|
||||
RowVectorXd h = m_pRbm->toHidden(DrawTraining->getData());
|
||||
DrawHidden->setData(h);
|
||||
|
||||
RowVectorXd v = m_pRbm->toVisible(DrawHidden->getData());
|
||||
DrawReconstruction->setData(v);
|
||||
|
||||
// RowVectorXd dataV(m_weights->getNumVisible());
|
||||
// DrawHidden->setData(m_pRbm->toHidden(dataV));
|
||||
|
||||
// RowVectorXd dataH(m_weights->getNumHidden());
|
||||
// VectorXd v = m_pRbm->toVisible(dataH);
|
||||
// DrawReconstruction->setData(v);
|
||||
uint32_t i;
|
||||
VectorXd V, H;
|
||||
|
||||
V = DrawTraining->getData();
|
||||
for (i=0; i < numIter; i++)
|
||||
{
|
||||
H = m_pRbm->toHidden(V);
|
||||
DrawHidden->setData(H);
|
||||
V = m_pRbm->toVisible(H);
|
||||
DrawReconstruction->setData(V);
|
||||
}
|
||||
|
||||
if ((m_vNumX == 27) && (m_vNumY == 4))
|
||||
{
|
||||
@@ -933,14 +928,14 @@ void MainComponent::redrawWeights(int index)
|
||||
{
|
||||
VectorXd w = m_weights->weights().col(index);
|
||||
DrawWeights->setData(w);
|
||||
DrawVars->setData(m_weights->sigma());
|
||||
DrawVars->setData(m_pRbm->getSigma());
|
||||
|
||||
}
|
||||
|
||||
void MainComponent::run()
|
||||
{
|
||||
// trainButton->setEnabled(false);
|
||||
m_pRbm->train(m_layers, numEpochslabel->getText().getIntValue(), 100);
|
||||
m_pRbm->train(m_layers, numEpochslabel->getText().getIntValue());
|
||||
// trainButton->setEnabled(true);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user