- removed classes HiddenLayer.hpp and VisibleLayer.hpp
- fixed warnings
- RbmComponent inherits Rbm
- improved Rbm::train
- use gaussion weight initialization

git-svn-id: http://moon:8086/svn/software/trunk/projects/RBM@297 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
2016-06-19 19:52:41 +00:00
parent 1705287e37
commit 9d00654932
9 changed files with 303 additions and 504 deletions
+13 -103
View File
@@ -24,7 +24,8 @@
//==============================================================================
RbmComponent::RbmComponent (Weights &weights, MatrixXd const &batch, RbmComponentListener &listener)
: m_weights(weights)
: Rbm(weights, batch)
, m_weights(weights)
, m_listener(listener)
, m_currWeightIndexToDraw(0)
, m_currTrainingIndexToDraw(0)
@@ -35,7 +36,6 @@ RbmComponent::RbmComponent (Weights &weights, MatrixXd const &batch, RbmComponen
{
//[UserPreSize]
m_pRbm = new Rbm(m_weights, batch, this);
size_t vNumX = m_weights.getNumVisibleX();
size_t vNumY = m_weights.getNumVisibleY();
size_t hNum = m_weights.getNumHidden();
@@ -69,7 +69,6 @@ RbmComponent::~RbmComponent()
DrawWeights = nullptr;
DrawVars = nullptr;
DrawHidden = nullptr;
m_pRbm = nullptr;
//[/Destructor]
}
@@ -204,13 +203,13 @@ void RbmComponent::mouseWheelMove (const MouseEvent& e, const MouseWheelDetails&
//[/UserCode_mouseWheelMove]
}
void RbmComponent::onProgressChanged(const Rbm &obj)
void RbmComponent::onProgressChanged()
{
// mylog("Training %f %%\n", obj.getProgress()*100);
upPass(DrawHidden->getData());
redrawReconstruction();
redrawWeights();
m_listener.onProgressChanged((size_t)(100*obj.getProgress() + 0.5));
m_listener.onProgressChanged((size_t)(100*getProgress() + 0.5));
}
void RbmComponent::onDraw(DrawComponent &obj)
@@ -229,15 +228,11 @@ void RbmComponent::redrawReconstruction()
{
uint32_t i;
reconstructVisible(DrawReconstruction->getData(), DrawTraining->getData());
// toHidden(DrawHidden->getData(), DrawTraining->getData());
// toVisible(DrawReconstruction->getData(), DrawHidden->getData());
downPass(DrawReconstruction->getData(), DrawTraining->getData());
for (i=0; i < m_pRbm->params().m_numGibbs-1; i++)
for (i=0; i < params().m_numGibbs-1; i++)
{
reconstructVisible(DrawReconstruction->getData(), DrawReconstruction->getData());
// toHidden(DrawHidden->getData(), DrawReconstruction->getData());
// toVisible(DrawReconstruction->getData(), DrawHidden->getData());
downPass(DrawReconstruction->getData(), DrawReconstruction->getData());
}
DrawReconstruction->DrawData();
}
@@ -250,94 +245,20 @@ void RbmComponent::redrawWeights()
void RbmComponent::redrawVariances()
{
DrawVars->getData() = m_pRbm->getVariableSigma();
DrawVars->getData() = getVariableSigma();
DrawVars->DrawData();
}
void RbmComponent::setDoLearnVariance(bool value)
void RbmComponent::onParamsChanged()
{
m_pRbm->setDoLearnVariance(value);
redrawWeights();
redrawVariances();
redrawReconstruction();
}
void RbmComponent::setDoRaoBlackwell(bool enable)
{
m_pRbm->setDoRaoBlackwell(enable);
}
void RbmComponent::setUseProbsForHiddenReconstruction(bool enable)
{
m_pRbm->setUseProbsForHiddenReconstruction(enable);
}
void RbmComponent::setUseVisibleGaussian(bool enable)
{
m_pRbm->setUseVisibleGaussian(enable);
}
void RbmComponent::setDoSparse(bool enable)
{
m_pRbm->setDoSparse(enable);
}
void RbmComponent::setLambda(double value)
{
m_pRbm->setLambda(value);
}
void RbmComponent::setSigmaDecay(double value)
{
m_pRbm->setSigmaDecay(value);
}
void RbmComponent::setWeightDecay(double value)
{
m_pRbm->setWeightDecay(value);
}
void RbmComponent::setSparsity(double value)
{
m_pRbm->setSparsity(value);
}
void RbmComponent::setNumGibbs(size_t value)
{
m_pRbm->setNumGibbs(value);
redrawReconstruction();
}
void RbmComponent::setSigma(double value)
{
m_pRbm->setConstantSigma(value);
redrawVariances();
redrawReconstruction();
}
void RbmComponent::setNormalizeData(bool enable)
{
m_pRbm->setNormalizeData(enable);
}
void RbmComponent::setMuWeights(double value)
{
m_pRbm->setMuWeights(value);
}
void RbmComponent::setMuSparsity(double value)
{
m_pRbm->setMuSparsity(value);
}
void RbmComponent::setMomentum(double value)
{
m_pRbm->setMomentum(value);
}
void RbmComponent::batchchanged()
{
m_pRbm->updateHiddenBatch();
Rbm::updateHiddenBatch();
if (lower)
{
lower->batchchanged();
@@ -358,10 +279,10 @@ size_t RbmComponent::getWeightsIndex()
void RbmComponent::setTrainingIndex(size_t index)
{
if (m_pRbm->getBatch().rows() > 0)
if (getBatch().rows() > 0)
{
m_currTrainingIndexToDraw = index;
DrawTraining->getData() = m_pRbm->getBatch().row(index);
DrawTraining->getData() = getBatch().row(index);
DrawTraining->DrawData();
redrawReconstruction();
@@ -374,17 +295,6 @@ size_t RbmComponent::getTrainingIndex()
return m_currTrainingIndexToDraw;
}
void RbmComponent::copyReconstructionToTraining()
{
DrawTraining->getData() = DrawReconstruction->getData();
DrawTraining->DrawData();
}
void RbmComponent::train(size_t numEpochs)
{
m_pRbm->train(numEpochs);
}
RowVectorXd const& RbmComponent::getTrainingData()
{
return DrawTraining->getData();