- cleaned up

git-svn-id: http://moon:8086/svn/software/trunk/projects/Rbm@625 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
2019-11-07 16:35:00 +00:00
parent 4e21dd8114
commit 6ccffc119d
4 changed files with 13 additions and 105 deletions
+3 -2
View File
@@ -617,13 +617,14 @@ void MainComponent::sliderValueChanged (Slider* sliderThatWasMoved)
{ {
//[UserSliderCode_patterSlider] -- add your slider handling code here.. //[UserSliderCode_patterSlider] -- add your slider handling code here..
m_trainingIndex = (int)sliderThatWasMoved->getValue(); m_trainingIndex = (int)sliderThatWasMoved->getValue();
m_pLayer->setTrainingIndex(m_trainingData.row(m_trainingIndex)); m_pLayer->setTrainingData(m_trainingData.row(m_trainingIndex));
//[/UserSliderCode_patterSlider] //[/UserSliderCode_patterSlider]
} }
else if (sliderThatWasMoved == WeightsSlider) else if (sliderThatWasMoved == WeightsSlider)
{ {
//[UserSliderCode_WeightsSlider] -- add your slider handling code here.. //[UserSliderCode_WeightsSlider] -- add your slider handling code here..
m_weightIndex = (int)sliderThatWasMoved->getValue(); int weightIndex = (int)sliderThatWasMoved->getValue();
m_pLayer->redrawWeights(weightIndex);
//[/UserSliderCode_WeightsSlider] //[/UserSliderCode_WeightsSlider]
} }
else if (sliderThatWasMoved == numGibbsSlider) else if (sliderThatWasMoved == numGibbsSlider)
+2 -25
View File
@@ -26,7 +26,6 @@
RbmComponent::RbmComponent (const std::string &name, size_t id, size_t numVisibleX, size_t numVisibleY, size_t numHidden, RbmComponentListener *pListener) RbmComponent::RbmComponent (const std::string &name, size_t id, size_t numVisibleX, size_t numVisibleY, size_t numHidden, RbmComponentListener *pListener)
: Layer(name, id, numVisibleX, numVisibleY, numHidden) : Layer(name, id, numVisibleX, numVisibleY, numHidden)
, m_currWeightIndexToDraw(0) , m_currWeightIndexToDraw(0)
, m_currTrainingIndexToDraw(0)
, DrawTraining(nullptr) , DrawTraining(nullptr)
, DrawReconstruction(nullptr) , DrawReconstruction(nullptr)
, DrawWeights(nullptr) , DrawWeights(nullptr)
@@ -249,24 +248,12 @@ void RbmComponent::redrawWeights()
DrawWeights->DrawData(); DrawWeights->DrawData();
} }
void RbmComponent::onParamsChanged() void RbmComponent::redrawWeights(size_t index)
{
redrawWeights();
redrawReconstruction();
}
void RbmComponent::setWeightsIndex(size_t index)
{ {
m_currWeightIndexToDraw = index; m_currWeightIndexToDraw = index;
redrawWeights();
} }
size_t RbmComponent::getWeightsIndex() void RbmComponent::setTrainingData(arma::mat const& batch)
{
return m_currWeightIndexToDraw;
}
void RbmComponent::setTrainingIndex(arma::mat const& batch)
{ {
DrawTraining->getData() = batch; DrawTraining->getData() = batch;
DrawTraining->DrawData(); DrawTraining->DrawData();
@@ -275,16 +262,6 @@ void RbmComponent::setTrainingIndex(arma::mat const& batch)
upPass(DrawHidden->getData()); upPass(DrawHidden->getData());
} }
size_t RbmComponent::getTrainingIndex()
{
return m_currTrainingIndexToDraw;
}
arma::mat const& RbmComponent::getTrainingData()
{
return DrawTraining->getData();
}
arma::mat const& RbmComponent::getTopWeights() arma::mat const& RbmComponent::getTopWeights()
{ {
if (upper) if (upper)
+7 -11
View File
@@ -98,15 +98,17 @@ public:
void mouseDoubleClick (const MouseEvent& e) override; void mouseDoubleClick (const MouseEvent& e) override;
void mouseWheelMove (const MouseEvent& e, const MouseWheelDetails& wheel) override; void mouseWheelMove (const MouseEvent& e, const MouseWheelDetails& wheel) override;
void setWeightsIndex(size_t index); void train(const arma::mat& batch)
size_t getWeightsIndex(); {
Layer::train(batch, this);
}
void setTrainingIndex(arma::mat const& batch); void setTrainingData(arma::mat const& batch);
size_t getTrainingIndex();
void redrawWeights(); void redrawWeights();
void redrawWeights(size_t index);
void redrawReconstruction(); void redrawReconstruction();
arma::mat const& getTrainingData();
void downPass(arma::mat &dst, arma::mat const &src) override void downPass(arma::mat &dst, arma::mat const &src) override
{ {
@@ -133,10 +135,6 @@ public:
arma::mat getConvolutedWeight(arma::mat const &h) override; arma::mat getConvolutedWeight(arma::mat const &h) override;
arma::mat const& getWeights() override; arma::mat const& getWeights() override;
void train(const arma::mat& batch)
{
Layer::train(batch, this);
}
private: private:
//[UserVariables] -- You can add your own custom variables in this section. //[UserVariables] -- You can add your own custom variables in this section.
RbmComponentListener *m_listener; RbmComponentListener *m_listener;
@@ -145,8 +143,6 @@ private:
ScopedPointer<DrawComponent> DrawWeights; ScopedPointer<DrawComponent> DrawWeights;
ScopedPointer<DrawComponent> DrawHidden; ScopedPointer<DrawComponent> DrawHidden;
size_t m_currWeightIndexToDraw; size_t m_currWeightIndexToDraw;
size_t m_currTrainingIndexToDraw;
void onParamsChanged();
bool onProgress(const Rbm::Status &status) override; bool onProgress(const Rbm::Status &status) override;
void onDraw(DrawComponent &obj) override; void onDraw(DrawComponent &obj) override;
//[/UserVariables] //[/UserVariables]
+1 -67
View File
@@ -22,74 +22,8 @@
} }
}, },
"weights_file" : "Layer.0.weights.dat" "weights_file" : "Layer.0.weights.dat"
},
{
"id" : 1,
"name" : "Layer",
"numHidden" : 4,
"numVisibleX" : 8,
"numVisibleY" : 1,
"rbm" : {
"params" : {
"doRaoBlackwell" : 1,
"doSampleBatch" : 0,
"gibbsDoSampleHidden" : 1,
"gibbsDoSampleVisible" : 0,
"learningRate" : 0.050000000000000003,
"miniBatchSize" : 100,
"momentum" : 0.5,
"numEpochs" : 500,
"numGibbs" : 1,
"weightDecay" : 0
}
},
"weights_file" : "Layer.1.weights.dat"
},
{
"id" : 2,
"name" : "Layer",
"numHidden" : 2,
"numVisibleX" : 4,
"numVisibleY" : 1,
"rbm" : {
"params" : {
"doRaoBlackwell" : 1,
"doSampleBatch" : 0,
"gibbsDoSampleHidden" : 1,
"gibbsDoSampleVisible" : 0,
"learningRate" : 0.025000000000000001,
"miniBatchSize" : 100,
"momentum" : 0.5,
"numEpochs" : 250,
"numGibbs" : 1,
"weightDecay" : 0
}
},
"weights_file" : "Layer.2.weights.dat"
},
{
"id" : 3,
"name" : "Layer",
"numHidden" : 1,
"numVisibleX" : 2,
"numVisibleY" : 1,
"rbm" : {
"params" : {
"doRaoBlackwell" : 1,
"doSampleBatch" : 0,
"gibbsDoSampleHidden" : 1,
"gibbsDoSampleVisible" : 0,
"learningRate" : 0.012500000000000001,
"miniBatchSize" : 100,
"momentum" : 0.5,
"numEpochs" : 125,
"numGibbs" : 1,
"weightDecay" : 0
}
},
"weights_file" : "Layer.3.weights.dat"
} }
], ]
"name" : "test" "name" : "test"
} }
} }