[RBM]
- pulled LayerArray out of RbmComponent git-svn-id: http://moon:8086/svn/software/trunk/projects/RBM@293 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
+8
-33
@@ -23,7 +23,6 @@
|
||||
//[Headers] -- You can add your own extra header files here --
|
||||
#include "JuceHeader.h"
|
||||
#include "DrawComponent.h"
|
||||
#include "LayerArray.hpp"
|
||||
#include "Rbm.hpp"
|
||||
//[/Headers]
|
||||
|
||||
@@ -34,7 +33,6 @@ public:
|
||||
virtual ~RbmComponentListener()
|
||||
{
|
||||
}
|
||||
virtual void onLayerSizeChanged(size_t size) = 0;
|
||||
virtual void onRbmEpochTrained(size_t progressPercent) = 0;
|
||||
};
|
||||
|
||||
@@ -48,13 +46,12 @@ public:
|
||||
//[/Comments]
|
||||
*/
|
||||
class RbmComponent : public Component,
|
||||
public LayerArrayListener,
|
||||
public RbmListener,
|
||||
public DrawListener
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
RbmComponent (Weights &weights, RbmComponentListener &listener);
|
||||
RbmComponent (Weights &weights, MatrixXd const &batch, RbmComponentListener &listener);
|
||||
~RbmComponent();
|
||||
|
||||
//==============================================================================
|
||||
@@ -109,8 +106,6 @@ public:
|
||||
DrawReconstruction->getData() = DrawTraining->getData();
|
||||
DrawReconstruction->DrawData();
|
||||
|
||||
m_layers.add(DrawTraining->getData(), m_weights.getNumVisible());
|
||||
m_listener.onLayerSizeChanged(m_layers.getSize());
|
||||
}
|
||||
|
||||
void selectWeights(size_t index)
|
||||
@@ -121,12 +116,10 @@ public:
|
||||
|
||||
void selectTraining(size_t index)
|
||||
{
|
||||
if (m_layers.getSize() > 0)
|
||||
if (m_pRbm->getBatch().rows() > 0)
|
||||
{
|
||||
m_currTrainingIndexToDraw = index;
|
||||
RowVectorXd t = m_layers.getAt(index);
|
||||
|
||||
DrawTraining->getData() = t;
|
||||
DrawTraining->getData() = m_pRbm->getBatch().row(index);
|
||||
DrawTraining->DrawData();
|
||||
|
||||
redrawReconstruction();
|
||||
@@ -139,27 +132,6 @@ public:
|
||||
DrawTraining->DrawData();
|
||||
}
|
||||
|
||||
void clearTraining()
|
||||
{
|
||||
m_layers.clear();
|
||||
}
|
||||
|
||||
void loadTraining(const char *pFilename)
|
||||
{
|
||||
m_layers.clear();
|
||||
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)
|
||||
@@ -167,6 +139,11 @@ public:
|
||||
m_pRbm->train(numEpochs);
|
||||
}
|
||||
|
||||
RowVectorXd const& getTrainingData()
|
||||
{
|
||||
return DrawTraining->getData();
|
||||
}
|
||||
|
||||
private:
|
||||
//[UserVariables] -- You can add your own custom variables in this section.
|
||||
ScopedPointer<Rbm> m_pRbm;
|
||||
@@ -177,10 +154,8 @@ private:
|
||||
ScopedPointer<DrawComponent> DrawWeights;
|
||||
ScopedPointer<DrawComponent> DrawVars;
|
||||
ScopedPointer<DrawComponent> DrawHidden;
|
||||
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]
|
||||
|
||||
Reference in New Issue
Block a user