- added gui code
git-svn-id: http://moon:8086/svn/software/trunk/projects/Rbm@620 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
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.hpp"
|
||||
#include "Layer.hpp"
|
||||
//[/Headers]
|
||||
|
||||
|
||||
class IRbmComponent
|
||||
{
|
||||
public:
|
||||
IRbmComponent *upper;
|
||||
IRbmComponent *lower;
|
||||
|
||||
IRbmComponent()
|
||||
: upper(nullptr)
|
||||
, lower(nullptr)
|
||||
{}
|
||||
virtual ~IRbmComponent()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void downPass(arma::mat &dst, arma::mat const &src) = 0;
|
||||
virtual void upPass(arma::mat const &v) = 0;
|
||||
void registerRbm(IRbmComponent *pObj)
|
||||
{
|
||||
lower = pObj;
|
||||
pObj->upper = this;
|
||||
}
|
||||
virtual arma::mat const& getTopWeights() = 0;
|
||||
virtual arma::mat getConvolutedWeight(arma::mat const &h) = 0;
|
||||
virtual arma::mat const& getWeights() = 0;
|
||||
};
|
||||
|
||||
class RbmComponentListener
|
||||
{
|
||||
public:
|
||||
RbmComponentListener() {}
|
||||
virtual ~RbmComponentListener()
|
||||
{
|
||||
}
|
||||
virtual void onProgressChanged(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 Layer
|
||||
, public DrawListener
|
||||
, public IRbmComponent
|
||||
, public Rbm::IListener
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
RbmComponent (const std::string &name, size_t id, size_t numVisibleX, size_t numVisibleY, size_t numHidden);
|
||||
~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 setWeightsIndex(size_t index);
|
||||
size_t getWeightsIndex();
|
||||
|
||||
void setTrainingIndex(arma::mat const& batch);
|
||||
size_t getTrainingIndex();
|
||||
|
||||
void redrawWeights();
|
||||
void redrawReconstruction();
|
||||
arma::mat const& getTrainingData();
|
||||
|
||||
void downPass(arma::mat &dst, arma::mat const &src) override
|
||||
{
|
||||
DrawHidden->getData() = toHiddenProbs(src);
|
||||
if (lower)
|
||||
{
|
||||
lower->downPass(DrawHidden->getData(), DrawHidden->getData());
|
||||
}
|
||||
dst = toVisibleProbs(DrawHidden->getData());
|
||||
DrawHidden->DrawData();
|
||||
}
|
||||
|
||||
void upPass(arma::mat const &h) override
|
||||
{
|
||||
DrawReconstruction->getData() = toVisibleProbs(h);
|
||||
DrawReconstruction->DrawData();
|
||||
if (upper)
|
||||
{
|
||||
upper->upPass(DrawReconstruction->getData());
|
||||
}
|
||||
}
|
||||
|
||||
arma::mat const& getTopWeights() override;
|
||||
arma::mat getConvolutedWeight(arma::mat const &h) override;
|
||||
arma::mat const& getWeights() override;
|
||||
|
||||
private:
|
||||
//[UserVariables] -- You can add your own custom variables in this section.
|
||||
RbmComponentListener *m_listener;
|
||||
ScopedPointer<DrawComponent> DrawTraining;
|
||||
ScopedPointer<DrawComponent> DrawReconstruction;
|
||||
ScopedPointer<DrawComponent> DrawWeights;
|
||||
ScopedPointer<DrawComponent> DrawHidden;
|
||||
size_t m_currWeightIndexToDraw;
|
||||
size_t m_currTrainingIndexToDraw;
|
||||
void onParamsChanged();
|
||||
bool onProgress(const Rbm::Status &status) 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