- enable on per default
git-svn-id: http://moon:8086/svn/software/trunk/projects/Rbm@657 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
+84
-89
@@ -34,115 +34,105 @@ RbmComponent::RbmComponent (const std::string &name, size_t id, size_t numVisibl
|
||||
addAndMakeVisible (DrawTraining = new DrawComponent (numVisibleX, numVisibleY));
|
||||
DrawTraining->setListener(this);
|
||||
|
||||
addAndMakeVisible (DrawHidden = new DrawComponent (numHidden, 1));
|
||||
addAndMakeVisible (DrawHidden = new DrawComponent (numHidden, 1));
|
||||
DrawHidden->setListener(this);
|
||||
|
||||
addAndMakeVisible (DrawReconstruction = new DrawComponent (numVisibleX, numVisibleY));
|
||||
addAndMakeVisible (DrawWeights = new DrawComponent (numVisibleX, numVisibleY, 0.5, 0.5));
|
||||
addAndMakeVisible (DrawReconstruction = new DrawComponent (numVisibleX, numVisibleY));
|
||||
addAndMakeVisible (DrawWeights = new DrawComponent (numVisibleX, numVisibleY, 0.5, 0.5));
|
||||
|
||||
addAndMakeVisible (m_toggleEnable = new ToggleButton ("Enable layer"));
|
||||
m_toggleEnable->setTooltip (TRANS("Enable layer for up pass"));
|
||||
m_toggleEnable->setButtonText (TRANS("Enable"));
|
||||
m_toggleEnable->addListener (this);
|
||||
|
||||
addAndMakeVisible (m_toggleEnable = new ToggleButton ("Enable layer"));
|
||||
m_toggleEnable->setTooltip (TRANS("Enable layer for up pass"));
|
||||
m_toggleEnable->setButtonText (TRANS("Enable"));
|
||||
m_toggleEnable->addListener (this);
|
||||
m_toggleEnable->setToggleState(true, NotificationType::dontSendNotification);
|
||||
redrawWeights();
|
||||
|
||||
setSize (430, 130);
|
||||
setSize (430, 130);
|
||||
resized();
|
||||
setBounds (16, 140*id+16, 430, 130);
|
||||
}
|
||||
|
||||
RbmComponent::~RbmComponent()
|
||||
{
|
||||
//[Destructor_pre]. You can add your own custom destruction code here..
|
||||
//[/Destructor_pre]
|
||||
|
||||
//[Destructor]. You can add your own custom destruction code here..
|
||||
DrawTraining = nullptr;
|
||||
DrawReconstruction = nullptr;
|
||||
DrawWeights = nullptr;
|
||||
DrawHidden = nullptr;
|
||||
//[/Destructor]
|
||||
DrawTraining = nullptr;
|
||||
DrawReconstruction = nullptr;
|
||||
DrawWeights = nullptr;
|
||||
DrawHidden = nullptr;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void RbmComponent::paint (Graphics& g)
|
||||
{
|
||||
//[UserPrePaint] Add your own custom painting code here..
|
||||
//[/UserPrePaint]
|
||||
g.fillAll (Colours::white);
|
||||
|
||||
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("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("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("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("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("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);
|
||||
|
||||
g.setColour (Colours::black);
|
||||
g.setFont (Font (15.00f, Font::plain));
|
||||
g.drawText (TRANS("Sigma decay"),
|
||||
296, 306, 96, 14,
|
||||
Justification::centred, true);
|
||||
g.setColour (Colours::black);
|
||||
g.setFont (Font (15.00f, Font::plain));
|
||||
g.drawText (TRANS("Weight decay"),
|
||||
296, 354, 96, 14,
|
||||
Justification::centred, true);
|
||||
|
||||
g.setColour (Colours::black);
|
||||
g.setFont (Font (15.00f, Font::plain));
|
||||
g.drawText (TRANS("Weight decay"),
|
||||
296, 354, 96, 14,
|
||||
Justification::centred, true);
|
||||
g.setColour (Colours::black);
|
||||
g.setFont (Font (15.00f, Font::plain));
|
||||
g.drawText (TRANS("Momentum"),
|
||||
208, 354, 80, 14,
|
||||
Justification::centred, true);
|
||||
|
||||
g.setColour (Colours::black);
|
||||
g.setFont (Font (15.00f, Font::plain));
|
||||
g.drawText (TRANS("Momentum"),
|
||||
208, 354, 80, 14,
|
||||
Justification::centred, true);
|
||||
g.setColour (Colours::black);
|
||||
g.setFont (Font (15.00f, Font::plain));
|
||||
g.drawText (TRANS("Sparsity Alpha"),
|
||||
408, 306, 96, 14,
|
||||
Justification::centred, true);
|
||||
|
||||
g.setColour (Colours::black);
|
||||
g.setFont (Font (15.00f, Font::plain));
|
||||
g.drawText (TRANS("Sparsity Alpha"),
|
||||
408, 306, 96, 14,
|
||||
Justification::centred, true);
|
||||
g.setColour (Colours::black);
|
||||
g.setFont (Font (15.00f, Font::plain));
|
||||
g.drawText (TRANS("Weight init"),
|
||||
408, 354, 96, 14,
|
||||
Justification::centred, true);
|
||||
|
||||
g.setColour (Colours::black);
|
||||
g.setFont (Font (15.00f, Font::plain));
|
||||
g.drawText (TRANS("Weight init"),
|
||||
408, 354, 96, 14,
|
||||
Justification::centred, true);
|
||||
|
||||
//[UserPaint] Add your own custom painting code here..
|
||||
//[/UserPaint]
|
||||
}
|
||||
|
||||
void RbmComponent::resized()
|
||||
{
|
||||
DrawTraining->setBoundsRelative(0, 0, 100./430, 100./130);
|
||||
DrawReconstruction->setBoundsRelative(110./430, 0, 100./430, 100./130);
|
||||
DrawWeights->setBoundsRelative (220./430, 0, 100./430, 100./130);
|
||||
DrawHidden->setBoundsRelative (0, 110./130, 430./430, 20./130);
|
||||
DrawWeights->setBoundsRelative (220./430, 0, 100./430, 100./130);
|
||||
DrawHidden->setBoundsRelative (0, 110./130, 430./430, 20./130);
|
||||
m_toggleEnable->setBoundsRelative (330./430, 0, 80./430, 24./130);
|
||||
}
|
||||
|
||||
@@ -212,11 +202,11 @@ void RbmComponent::buttonClicked(Button* buttonThatWasClicked)
|
||||
{
|
||||
if (buttonThatWasClicked == m_toggleEnable)
|
||||
{
|
||||
bool state = isEnabled();
|
||||
bool state = buttonThatWasClicked->getToggleState();
|
||||
if (next)
|
||||
{
|
||||
RbmComponent *pComp = static_cast<RbmComponent*> (next);
|
||||
pComp->enable(state);
|
||||
pComp->m_toggleEnable->setToggleState(state, NotificationType::sendNotification);
|
||||
}
|
||||
redrawReconstruction();
|
||||
}
|
||||
@@ -229,15 +219,24 @@ void RbmComponent::redrawReconstruction()
|
||||
|
||||
}
|
||||
|
||||
void RbmComponent::gibbs(const arma::mat& v)
|
||||
{
|
||||
arma::mat r = v;
|
||||
for (int i=0; i < params().numGibbs; i++)
|
||||
{
|
||||
DrawHidden->getData() = toHiddenProbs(r);
|
||||
r = toVisibleProbs(DrawHidden->getData());
|
||||
}
|
||||
DrawReconstruction->getData() = r;
|
||||
DrawReconstruction->DrawData();
|
||||
DrawHidden->DrawData();
|
||||
}
|
||||
|
||||
void RbmComponent::upPass(const arma::mat& v)
|
||||
{
|
||||
DrawTraining->getData() = v;
|
||||
DrawTraining->DrawData();
|
||||
DrawHidden->getData() = toHiddenProbs(v);
|
||||
DrawHidden->DrawData();
|
||||
DrawReconstruction->getData() = toVisibleProbs(DrawHidden->getData());
|
||||
DrawReconstruction->DrawData();
|
||||
|
||||
gibbs(v);
|
||||
if (next)
|
||||
{
|
||||
RbmComponent *pComp = static_cast<RbmComponent*> (next);
|
||||
@@ -262,15 +261,11 @@ void RbmComponent::upDownPass(const arma::mat& v)
|
||||
{
|
||||
DrawTraining->getData() = v;
|
||||
DrawTraining->DrawData();
|
||||
DrawHidden->getData() = toHiddenProbs(v);
|
||||
DrawHidden->DrawData();
|
||||
DrawReconstruction->getData() = toVisibleProbs(DrawHidden->getData());
|
||||
DrawReconstruction->DrawData();
|
||||
|
||||
gibbs(v);
|
||||
if (next)
|
||||
{
|
||||
RbmComponent *pComp = static_cast<RbmComponent*> (next);
|
||||
if (pComp->isEnabled())
|
||||
if (pComp->m_toggleEnable->getToggleState())
|
||||
{
|
||||
pComp->upDownPass(DrawHidden->getData());
|
||||
}
|
||||
|
||||
@@ -78,16 +78,8 @@ private:
|
||||
ScopedPointer<DrawComponent> DrawReconstruction;
|
||||
ScopedPointer<DrawComponent> DrawWeights;
|
||||
ScopedPointer<ToggleButton> m_toggleEnable;
|
||||
bool isEnabled()
|
||||
{
|
||||
return m_toggleEnable->getToggleState();
|
||||
}
|
||||
|
||||
void enable(bool state)
|
||||
{
|
||||
m_toggleEnable->setToggleState(state, NotificationType::sendNotification);
|
||||
}
|
||||
|
||||
void gibbs(const arma::mat& v);
|
||||
size_t m_currWeightIndexToDraw;
|
||||
void onDraw(DrawComponent &obj) override;
|
||||
void buttonClicked(Button* buttonThatWasClicked) override;
|
||||
|
||||
Reference in New Issue
Block a user