- LayerArray: added copy constructor

- minor changes

git-svn-id: http://moon:8086/svn/software/trunk/projects/RBM@42 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
2014-10-26 08:46:13 +00:00
parent 376f2dfa35
commit 6520c80eca
3 changed files with 19 additions and 6 deletions
+16 -2
View File
@@ -72,6 +72,20 @@ public:
} }
} }
LayerArray (const LayerArray<T> &rhs)
: m_size(0)
, m_pRoot(nullptr)
, m_ppIndex(nullptr)
, m_pListener(nullptr)
{
uint32_t i;
for (i=0; i < rhs.getSize(); i++)
{
this->add(&rhs[i].states(), rhs[i].states().size());
}
}
virtual ~LayerArray() virtual ~LayerArray()
{ {
m_pListener = nullptr; m_pListener = nullptr;
@@ -125,12 +139,12 @@ public:
m_pListener->onChanged(*this); m_pListener->onChanged(*this);
} }
T& getAt(uint32_t index) T& getAt(uint32_t index) const
{ {
return *m_ppIndex[index]; return *m_ppIndex[index];
} }
T& operator[](uint32_t index) T& operator[](uint32_t index) const
{ {
return getAt(index); return getAt(index);
} }
-3
View File
@@ -477,10 +477,7 @@ void MainComponent::buttonClicked (Button* buttonThatWasClicked)
if (buttonThatWasClicked == trainButton) if (buttonThatWasClicked == trainButton)
{ {
//[UserButtonCode_trainButton] -- add your button handler code here.. //[UserButtonCode_trainButton] -- add your button handler code here..
// m_pRbm->train(m_layers, numEpochslabel->getText().getIntValue(), learningRateLabel->getText().getFloatValue(), m_numGibbs);
startThread(); startThread();
redrawReconstruction();
redrawWeights((int)WeightsSlider->getValue());
//[/UserButtonCode_trainButton] //[/UserButtonCode_trainButton]
} }
else if (buttonThatWasClicked == addButton) else if (buttonThatWasClicked == addButton)
+3 -1
View File
@@ -63,7 +63,7 @@ public:
Noise_Free(&m_noise); Noise_Free(&m_noise);
} }
void train(LayerArray<VisibleLayer> &vt, uint32_t numEpochs, double sigmaMin = 0.05) void train(const LayerArray<VisibleLayer> &batch, uint32_t numEpochs, double sigmaMin = 0.05)
{ {
uint32_t t, i; uint32_t t, i;
uint32_t epoch; uint32_t epoch;
@@ -81,6 +81,8 @@ public:
MatrixXd sumWeights(m_w.getNumVisible(), m_w.getNumHidden()); MatrixXd sumWeights(m_w.getNumVisible(), m_w.getNumHidden());
MatrixXd deltaWeights(m_w.getNumVisible(), m_w.getNumHidden()); MatrixXd deltaWeights(m_w.getNumVisible(), m_w.getNumHidden());
const LayerArray<VisibleLayer> &vt = batch;
sigma = m_sigma; sigma = m_sigma;
double dProgress = 1.0/numEpochs; double dProgress = 1.0/numEpochs;