[RBM]
- introduce RbmComponent git-svn-id: http://moon:8086/svn/software/trunk/projects/RBM@288 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
@@ -0,0 +1,194 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This is an automatically generated GUI class created by the Introjucer!
|
||||
|
||||
Be careful when adding custom code to these files, as only the code within
|
||||
the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded
|
||||
and re-saved.
|
||||
|
||||
Created with Introjucer version: 3.1.0
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
The Introjucer is part of the JUCE library - "Jules' Utility Class Extensions"
|
||||
Copyright 2004-13 by Raw Material Software Ltd.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#ifndef __RBM_COMPONENT__
|
||||
#define __RBM_COMPONENT__
|
||||
|
||||
//[Headers] -- You can add your own extra header files here --
|
||||
#include "JuceHeader.h"
|
||||
#include "DrawComponent.h"
|
||||
#include "LayerArray.hpp"
|
||||
#include "Rbm.hpp"
|
||||
//[/Headers]
|
||||
|
||||
class RbmComponentListener
|
||||
{
|
||||
public:
|
||||
RbmComponentListener() {}
|
||||
virtual ~RbmComponentListener()
|
||||
{
|
||||
}
|
||||
virtual void onLayerSizeChanged(size_t size) = 0;
|
||||
virtual void onRbmEpochTrained(size_t progressPercent) = 0;
|
||||
};
|
||||
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
//[Comments]
|
||||
An auto-generated component, created by the Introjucer.
|
||||
|
||||
Describe your class and how it works here!
|
||||
//[/Comments]
|
||||
*/
|
||||
class RbmComponent : public Component,
|
||||
public LayerArrayListener,
|
||||
public RbmListener,
|
||||
public DrawListener
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
RbmComponent (Weights &weights, RbmComponentListener &listener);
|
||||
~RbmComponent();
|
||||
|
||||
//==============================================================================
|
||||
//[UserMethods] -- You can add your own custom methods in this section.
|
||||
//[/UserMethods]
|
||||
|
||||
void paint (Graphics& g);
|
||||
void resized() override;
|
||||
void mouseMove (const MouseEvent& e) override;
|
||||
void mouseEnter (const MouseEvent& e) override;
|
||||
void mouseExit (const MouseEvent& e) override;
|
||||
void mouseDown (const MouseEvent& e) override;
|
||||
void mouseDrag (const MouseEvent& e) override;
|
||||
void mouseUp (const MouseEvent& e) override;
|
||||
void mouseDoubleClick (const MouseEvent& e) override;
|
||||
void mouseWheelMove (const MouseEvent& e, const MouseWheelDetails& wheel) override;
|
||||
|
||||
void setDoLearnVariance(bool value);
|
||||
void setDoRaoBlackwell(bool enable);
|
||||
void setUseProbsForHiddenReconstruction(bool enable);
|
||||
void setUseVisibleGaussian(bool enable);
|
||||
void setDoSparse(bool enable);
|
||||
void setNormalizeData(bool enable)
|
||||
{
|
||||
m_pRbm->setNormalizeData(enable);
|
||||
}
|
||||
|
||||
void setLambda(double value);
|
||||
void setSigmaDecay(double value);
|
||||
void setWeightDecay(double value);
|
||||
void setSparsity(double value);
|
||||
void setNumGibbs(size_t value);
|
||||
void setSigma(double value);
|
||||
|
||||
void setMuWeights(double value)
|
||||
{
|
||||
m_pRbm->setMuWeights(value);
|
||||
}
|
||||
|
||||
void setMuSparsity(double value)
|
||||
{
|
||||
m_pRbm->setMuSparsity(value);
|
||||
}
|
||||
|
||||
void setMomentum(double value)
|
||||
{
|
||||
m_pRbm->setMomentum(value);
|
||||
}
|
||||
|
||||
void addFromTraining()
|
||||
{
|
||||
DrawReconstruction->setData(DrawTraining->getData());
|
||||
m_layers.add(DrawTraining->getData(), m_vNumX*m_vNumY);
|
||||
m_listener.onLayerSizeChanged(m_layers.getSize());
|
||||
}
|
||||
|
||||
void selectWeights(size_t index)
|
||||
{
|
||||
m_currWeightIndexToDraw = index;
|
||||
redrawWeights();
|
||||
}
|
||||
|
||||
void selectTraining(size_t index)
|
||||
{
|
||||
if (m_layers.getSize() > 0)
|
||||
{
|
||||
m_currTrainingIndexToDraw = index;
|
||||
RowVectorXd t = m_layers.getAt(index);
|
||||
|
||||
DrawTraining->setData(t);
|
||||
redrawReconstruction();
|
||||
}
|
||||
}
|
||||
|
||||
void copyReconstructionToTraining()
|
||||
{
|
||||
DrawTraining->setData(DrawReconstruction->getData());
|
||||
}
|
||||
|
||||
void clearTraining()
|
||||
{
|
||||
m_layers.clear();
|
||||
}
|
||||
|
||||
void loadTraining(const char *pFilename)
|
||||
{
|
||||
m_layers.load(pFilename);
|
||||
}
|
||||
|
||||
void saveTraining(const char *pFilename)
|
||||
{
|
||||
m_layers.save(pFilename);
|
||||
}
|
||||
|
||||
void removeTrainingAt(size_t index)
|
||||
{
|
||||
m_layers.removeAt(index);
|
||||
}
|
||||
|
||||
void redrawWeights();
|
||||
void redrawReconstruction();
|
||||
void train(size_t numEpochs)
|
||||
{
|
||||
m_pRbm->train(m_layers, numEpochs);
|
||||
}
|
||||
|
||||
private:
|
||||
//[UserVariables] -- You can add your own custom variables in this section.
|
||||
ScopedPointer<Rbm> m_pRbm;
|
||||
Weights &m_weights;
|
||||
RbmComponentListener &m_listener;
|
||||
ScopedPointer<DrawComponent> DrawTraining;
|
||||
ScopedPointer<DrawComponent> DrawReconstruction;
|
||||
ScopedPointer<DrawComponent> DrawWeights;
|
||||
ScopedPointer<DrawComponent> DrawVars;
|
||||
ScopedPointer<DrawComponent> DrawHidden;
|
||||
uint32_t m_vNumX;
|
||||
uint32_t m_vNumY;
|
||||
uint32_t m_hNum;
|
||||
LayerArray m_layers;
|
||||
size_t m_currWeightIndexToDraw;
|
||||
size_t m_currTrainingIndexToDraw;
|
||||
void onChanged(const LayerArray &obj) override;
|
||||
void onEpochTrained(const Rbm &obj) override;
|
||||
void onDraw(DrawComponent &obj) override;
|
||||
//[/UserVariables]
|
||||
|
||||
//==============================================================================
|
||||
|
||||
//==============================================================================
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (RbmComponent)
|
||||
};
|
||||
|
||||
//[EndFile] You can add extra defines here...
|
||||
//[/EndFile]
|
||||
|
||||
#endif // __RBM_COMPONENT__
|
||||
Reference in New Issue
Block a user