[RBM]
- moved sigma and mean from WEIGHTS to RBM - use Gibbs slider also for reconstruction draw git-svn-id: http://moon:8086/svn/software/trunk/projects/RBM@287 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
+33
-38
@@ -74,7 +74,7 @@ MainComponent::MainComponent ()
|
|||||||
WeightsSlider->addListener (this);
|
WeightsSlider->addListener (this);
|
||||||
|
|
||||||
addAndMakeVisible (numEpochslabel = new Label ("Num Epochs label",
|
addAndMakeVisible (numEpochslabel = new Label ("Num Epochs label",
|
||||||
TRANS("100")));
|
TRANS("1000")));
|
||||||
numEpochslabel->setFont (Font (15.00f, Font::plain));
|
numEpochslabel->setFont (Font (15.00f, Font::plain));
|
||||||
numEpochslabel->setJustificationType (Justification::centred);
|
numEpochslabel->setJustificationType (Justification::centred);
|
||||||
numEpochslabel->setEditable (true, true, false);
|
numEpochslabel->setEditable (true, true, false);
|
||||||
@@ -118,7 +118,7 @@ MainComponent::MainComponent ()
|
|||||||
createButton->addListener (this);
|
createButton->addListener (this);
|
||||||
|
|
||||||
addAndMakeVisible (projectNameLabel = new Label ("Project Name label",
|
addAndMakeVisible (projectNameLabel = new Label ("Project Name label",
|
||||||
TRANS("TestPrj")));
|
TRANS("test")));
|
||||||
projectNameLabel->setFont (Font (15.00f, Font::plain));
|
projectNameLabel->setFont (Font (15.00f, Font::plain));
|
||||||
projectNameLabel->setJustificationType (Justification::centred);
|
projectNameLabel->setJustificationType (Justification::centred);
|
||||||
projectNameLabel->setEditable (true, true, false);
|
projectNameLabel->setEditable (true, true, false);
|
||||||
@@ -482,14 +482,14 @@ void MainComponent::buttonClicked (Button* buttonThatWasClicked)
|
|||||||
else if (buttonThatWasClicked == reconstructButton)
|
else if (buttonThatWasClicked == reconstructButton)
|
||||||
{
|
{
|
||||||
//[UserButtonCode_reconstructButton] -- add your button handler code here..
|
//[UserButtonCode_reconstructButton] -- add your button handler code here..
|
||||||
redrawReconstruction();
|
redrawReconstruction(numGibbsSlider->getValue());
|
||||||
//[/UserButtonCode_reconstructButton]
|
//[/UserButtonCode_reconstructButton]
|
||||||
}
|
}
|
||||||
else if (buttonThatWasClicked == ShakeButton)
|
else if (buttonThatWasClicked == ShakeButton)
|
||||||
{
|
{
|
||||||
//[UserButtonCode_ShakeButton] -- add your button handler code here..
|
//[UserButtonCode_ShakeButton] -- add your button handler code here..
|
||||||
m_weights->shuffle(weightInitLabel->getText().getFloatValue());
|
m_weights->shuffle(weightInitLabel->getText().getFloatValue());
|
||||||
redrawReconstruction();
|
redrawReconstruction(numGibbsSlider->getValue());
|
||||||
redrawWeights((int)WeightsSlider->getValue());
|
redrawWeights((int)WeightsSlider->getValue());
|
||||||
//[/UserButtonCode_ShakeButton]
|
//[/UserButtonCode_ShakeButton]
|
||||||
}
|
}
|
||||||
@@ -497,7 +497,7 @@ void MainComponent::buttonClicked (Button* buttonThatWasClicked)
|
|||||||
{
|
{
|
||||||
//[UserButtonCode_testButton] -- add your button handler code here..
|
//[UserButtonCode_testButton] -- add your button handler code here..
|
||||||
DrawTraining->setData(DrawReconstruction->getData());
|
DrawTraining->setData(DrawReconstruction->getData());
|
||||||
redrawReconstruction();
|
redrawReconstruction(numGibbsSlider->getValue());
|
||||||
//[/UserButtonCode_testButton]
|
//[/UserButtonCode_testButton]
|
||||||
}
|
}
|
||||||
else if (buttonThatWasClicked == createButton)
|
else if (buttonThatWasClicked == createButton)
|
||||||
@@ -546,17 +546,7 @@ void MainComponent::buttonClicked (Button* buttonThatWasClicked)
|
|||||||
else if (buttonThatWasClicked == reconstructEquButton)
|
else if (buttonThatWasClicked == reconstructEquButton)
|
||||||
{
|
{
|
||||||
//[UserButtonCode_reconstructEquButton] -- add your button handler code here..
|
//[UserButtonCode_reconstructEquButton] -- add your button handler code here..
|
||||||
uint32_t i;
|
redrawReconstruction(100);
|
||||||
VectorXd V, H;
|
|
||||||
|
|
||||||
V = DrawTraining->getData();
|
|
||||||
for (i=0; i < 100; i++)
|
|
||||||
{
|
|
||||||
H = m_pRbm->toHidden(V);
|
|
||||||
DrawHidden->setData(H);
|
|
||||||
V = m_pRbm->toVisible(H);
|
|
||||||
DrawReconstruction->setData(V);
|
|
||||||
}
|
|
||||||
//[/UserButtonCode_reconstructEquButton]
|
//[/UserButtonCode_reconstructEquButton]
|
||||||
}
|
}
|
||||||
else if (buttonThatWasClicked == rbmDoRaoBlackwellToggleButton)
|
else if (buttonThatWasClicked == rbmDoRaoBlackwellToggleButton)
|
||||||
@@ -575,7 +565,7 @@ void MainComponent::buttonClicked (Button* buttonThatWasClicked)
|
|||||||
{
|
{
|
||||||
//[UserButtonCode_rbmUseVisibleGaussianToggleButton] -- add your button handler code here..
|
//[UserButtonCode_rbmUseVisibleGaussianToggleButton] -- add your button handler code here..
|
||||||
m_pRbm->setUseVisibleGaussian(buttonThatWasClicked->getToggleState());
|
m_pRbm->setUseVisibleGaussian(buttonThatWasClicked->getToggleState());
|
||||||
redrawReconstruction();
|
redrawReconstruction(numGibbsSlider->getValue());
|
||||||
//[/UserButtonCode_rbmUseVisibleGaussianToggleButton]
|
//[/UserButtonCode_rbmUseVisibleGaussianToggleButton]
|
||||||
}
|
}
|
||||||
else if (buttonThatWasClicked == rbmDoSparseToggleButton)
|
else if (buttonThatWasClicked == rbmDoSparseToggleButton)
|
||||||
@@ -588,6 +578,10 @@ void MainComponent::buttonClicked (Button* buttonThatWasClicked)
|
|||||||
{
|
{
|
||||||
//[UserButtonCode_rbmLearnVarianceButton] -- add your button handler code here..
|
//[UserButtonCode_rbmLearnVarianceButton] -- add your button handler code here..
|
||||||
m_pRbm->setDoLearnVariance(buttonThatWasClicked->getToggleState());
|
m_pRbm->setDoLearnVariance(buttonThatWasClicked->getToggleState());
|
||||||
|
if (!buttonThatWasClicked->getToggleState())
|
||||||
|
{
|
||||||
|
m_pRbm->setSigma(sigmaLabel->getText().getFloatValue());
|
||||||
|
}
|
||||||
//[/UserButtonCode_rbmLearnVarianceButton]
|
//[/UserButtonCode_rbmLearnVarianceButton]
|
||||||
}
|
}
|
||||||
else if (buttonThatWasClicked == rbmNormalizeDataToggleButton)
|
else if (buttonThatWasClicked == rbmNormalizeDataToggleButton)
|
||||||
@@ -614,7 +608,7 @@ void MainComponent::sliderValueChanged (Slider* sliderThatWasMoved)
|
|||||||
RowVectorXd t = m_layers.getAt((int)sliderThatWasMoved->getValue());
|
RowVectorXd t = m_layers.getAt((int)sliderThatWasMoved->getValue());
|
||||||
|
|
||||||
DrawTraining->setData(t);
|
DrawTraining->setData(t);
|
||||||
redrawReconstruction();
|
redrawReconstruction(numGibbsSlider->getValue());
|
||||||
}
|
}
|
||||||
//[/UserSliderCode_patterSlider]
|
//[/UserSliderCode_patterSlider]
|
||||||
}
|
}
|
||||||
@@ -628,6 +622,7 @@ void MainComponent::sliderValueChanged (Slider* sliderThatWasMoved)
|
|||||||
{
|
{
|
||||||
//[UserSliderCode_numGibbsSlider] -- add your slider handling code here..
|
//[UserSliderCode_numGibbsSlider] -- add your slider handling code here..
|
||||||
m_pRbm->setNumGibbs((uint32_t)sliderThatWasMoved->getValue());
|
m_pRbm->setNumGibbs((uint32_t)sliderThatWasMoved->getValue());
|
||||||
|
redrawReconstruction(sliderThatWasMoved->getValue());
|
||||||
//[/UserSliderCode_numGibbsSlider]
|
//[/UserSliderCode_numGibbsSlider]
|
||||||
}
|
}
|
||||||
else if (sliderThatWasMoved == m_progressBarSlider)
|
else if (sliderThatWasMoved == m_progressBarSlider)
|
||||||
@@ -680,14 +675,16 @@ void MainComponent::labelTextChanged (Label* labelThatHasChanged)
|
|||||||
{
|
{
|
||||||
//[UserLabelCode_lambdaLabel] -- add your label text handling code here..
|
//[UserLabelCode_lambdaLabel] -- add your label text handling code here..
|
||||||
m_pRbm->setLambda(labelThatHasChanged->getText().getFloatValue());
|
m_pRbm->setLambda(labelThatHasChanged->getText().getFloatValue());
|
||||||
redrawReconstruction();
|
redrawReconstruction(numGibbsSlider->getValue());
|
||||||
//[/UserLabelCode_lambdaLabel]
|
//[/UserLabelCode_lambdaLabel]
|
||||||
}
|
}
|
||||||
else if (labelThatHasChanged == sigmaLabel)
|
else if (labelThatHasChanged == sigmaLabel)
|
||||||
{
|
{
|
||||||
//[UserLabelCode_sigmaLabel] -- add your label text handling code here..
|
//[UserLabelCode_sigmaLabel] -- add your label text handling code here..
|
||||||
m_pRbm->setSigma(labelThatHasChanged->getText().getFloatValue());
|
m_pRbm->setSigma(labelThatHasChanged->getText().getFloatValue());
|
||||||
redrawReconstruction();
|
DrawVars->setData(m_pRbm->getSigma());
|
||||||
|
redrawReconstruction(numGibbsSlider->getValue());
|
||||||
|
|
||||||
//[/UserLabelCode_sigmaLabel]
|
//[/UserLabelCode_sigmaLabel]
|
||||||
}
|
}
|
||||||
else if (labelThatHasChanged == sparsityLabel)
|
else if (labelThatHasChanged == sparsityLabel)
|
||||||
@@ -844,7 +841,7 @@ void MainComponent::create(const char *pFilename)
|
|||||||
|
|
||||||
resized();
|
resized();
|
||||||
|
|
||||||
redrawReconstruction();
|
redrawReconstruction(numGibbsSlider->getValue());
|
||||||
redrawWeights((int)WeightsSlider->getValue());
|
redrawWeights((int)WeightsSlider->getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -868,7 +865,7 @@ void MainComponent::onChanged(const LayerArray &obj)
|
|||||||
void MainComponent::onEpochTrained(const Rbm &obj)
|
void MainComponent::onEpochTrained(const Rbm &obj)
|
||||||
{
|
{
|
||||||
// mylog("Training %f %%\n", obj.getProgress()*100);
|
// mylog("Training %f %%\n", obj.getProgress()*100);
|
||||||
redrawReconstruction();
|
redrawReconstruction(numGibbsSlider->getValue());
|
||||||
redrawWeights((int)WeightsSlider->getValue());
|
redrawWeights((int)WeightsSlider->getValue());
|
||||||
m_progressBarSlider->setValue((int)(100*obj.getProgress()), dontSendNotification);
|
m_progressBarSlider->setValue((int)(100*obj.getProgress()), dontSendNotification);
|
||||||
}
|
}
|
||||||
@@ -881,25 +878,23 @@ void MainComponent::onDraw(DrawComponent &obj)
|
|||||||
}
|
}
|
||||||
if (&obj == DrawTraining)
|
if (&obj == DrawTraining)
|
||||||
{
|
{
|
||||||
redrawReconstruction();
|
redrawReconstruction(numGibbsSlider->getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainComponent::redrawReconstruction()
|
void MainComponent::redrawReconstruction(uint32_t numIter)
|
||||||
{
|
{
|
||||||
RowVectorXd h = m_pRbm->toHidden(DrawTraining->getData());
|
uint32_t i;
|
||||||
DrawHidden->setData(h);
|
VectorXd V, H;
|
||||||
|
|
||||||
RowVectorXd v = m_pRbm->toVisible(DrawHidden->getData());
|
|
||||||
DrawReconstruction->setData(v);
|
|
||||||
|
|
||||||
// RowVectorXd dataV(m_weights->getNumVisible());
|
|
||||||
// DrawHidden->setData(m_pRbm->toHidden(dataV));
|
|
||||||
|
|
||||||
// RowVectorXd dataH(m_weights->getNumHidden());
|
|
||||||
// VectorXd v = m_pRbm->toVisible(dataH);
|
|
||||||
// DrawReconstruction->setData(v);
|
|
||||||
|
|
||||||
|
V = DrawTraining->getData();
|
||||||
|
for (i=0; i < numIter; i++)
|
||||||
|
{
|
||||||
|
H = m_pRbm->toHidden(V);
|
||||||
|
DrawHidden->setData(H);
|
||||||
|
V = m_pRbm->toVisible(H);
|
||||||
|
DrawReconstruction->setData(V);
|
||||||
|
}
|
||||||
|
|
||||||
if ((m_vNumX == 27) && (m_vNumY == 4))
|
if ((m_vNumX == 27) && (m_vNumY == 4))
|
||||||
{
|
{
|
||||||
@@ -933,14 +928,14 @@ void MainComponent::redrawWeights(int index)
|
|||||||
{
|
{
|
||||||
VectorXd w = m_weights->weights().col(index);
|
VectorXd w = m_weights->weights().col(index);
|
||||||
DrawWeights->setData(w);
|
DrawWeights->setData(w);
|
||||||
DrawVars->setData(m_weights->sigma());
|
DrawVars->setData(m_pRbm->getSigma());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainComponent::run()
|
void MainComponent::run()
|
||||||
{
|
{
|
||||||
// trainButton->setEnabled(false);
|
// trainButton->setEnabled(false);
|
||||||
m_pRbm->train(m_layers, numEpochslabel->getText().getIntValue(), 100);
|
m_pRbm->train(m_layers, numEpochslabel->getText().getIntValue());
|
||||||
// trainButton->setEnabled(true);
|
// trainButton->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ private:
|
|||||||
void onChanged(const LayerArray &obj);
|
void onChanged(const LayerArray &obj);
|
||||||
void onEpochTrained(const Rbm &obj);
|
void onEpochTrained(const Rbm &obj);
|
||||||
void onDraw(DrawComponent &obj);
|
void onDraw(DrawComponent &obj);
|
||||||
void redrawReconstruction();
|
void redrawReconstruction(uint32_t numIter);
|
||||||
void redrawWeights(int index);
|
void redrawWeights(int index);
|
||||||
void run();
|
void run();
|
||||||
String m_baseDir;
|
String m_baseDir;
|
||||||
|
|||||||
+23
-21
@@ -41,9 +41,9 @@ public:
|
|||||||
: m_w(weights)
|
: m_w(weights)
|
||||||
, m_v(weights.getNumVisible())
|
, m_v(weights.getNumVisible())
|
||||||
, m_h(weights.getNumHidden())
|
, m_h(weights.getNumHidden())
|
||||||
|
, m_sigmas(weights.getNumVisible())
|
||||||
, m_pListener(pListener)
|
, m_pListener(pListener)
|
||||||
, m_progress(0)
|
, m_progress(0)
|
||||||
, m_sigma(1.0)
|
|
||||||
, m_sigmaDecay(1.0)
|
, m_sigmaDecay(1.0)
|
||||||
, m_weightDecay(0.0)
|
, m_weightDecay(0.0)
|
||||||
, m_lambda(1.0)
|
, m_lambda(1.0)
|
||||||
@@ -222,7 +222,7 @@ public:
|
|||||||
return t1;
|
return t1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void train(const LayerArray &vt, uint32_t numEpochs, uint32_t batchSize, double sigmaMin = 0.05)
|
void train(const LayerArray &vt, uint32_t numEpochs, double sigmaMin = 0.05)
|
||||||
{
|
{
|
||||||
uint32_t t, i;
|
uint32_t t, i;
|
||||||
uint32_t epoch;
|
uint32_t epoch;
|
||||||
@@ -230,7 +230,7 @@ public:
|
|||||||
double dProgress = 1.0/numEpochs;
|
double dProgress = 1.0/numEpochs;
|
||||||
double kTrain = 1.0/vt.getSize();
|
double kTrain = 1.0/vt.getSize();
|
||||||
|
|
||||||
batchSize = vt.getSize();
|
size_t batchSize = vt.getSize();
|
||||||
|
|
||||||
MatrixXd v(batchSize, m_w.getNumVisible());
|
MatrixXd v(batchSize, m_w.getNumVisible());
|
||||||
MatrixXd h(batchSize, m_w.getNumHidden());
|
MatrixXd h(batchSize, m_w.getNumHidden());
|
||||||
@@ -252,19 +252,18 @@ public:
|
|||||||
|
|
||||||
batch = vt.data();
|
batch = vt.data();
|
||||||
|
|
||||||
m_w.mean() = calcMean(batch);
|
|
||||||
|
|
||||||
if (m_doLearnVariance)
|
if (m_doLearnVariance)
|
||||||
{
|
{
|
||||||
m_w.sigma() = calcSigma(batch);
|
m_sigmas = calcSigma(batch);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_doNormalizeData)
|
if (m_doNormalizeData)
|
||||||
{
|
{
|
||||||
|
RowVectorXd mean = calcMean(batch);
|
||||||
for (i=0; i < batchSize; i++)
|
for (i=0; i < batchSize; i++)
|
||||||
{
|
{
|
||||||
RowVectorXd x = batch.row(i);
|
RowVectorXd x = batch.row(i);
|
||||||
batch.row(i) = normalizeData(x, m_w.mean(), m_w.sigma());
|
batch.row(i) = normalizeData(x, mean, m_sigmas);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,12 +309,12 @@ public:
|
|||||||
{
|
{
|
||||||
if (!m_useProbsForHiddenReconstruction)
|
if (!m_useProbsForHiddenReconstruction)
|
||||||
{
|
{
|
||||||
sampleGaussian(v, m_w.sigma().replicate(batchSize, 1));
|
sampleGaussian(v, m_sigmas.replicate(batchSize, 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
probsLogistic(v, m_w.sigma().replicate(batchSize, 1));
|
probsLogistic(v, m_sigmas.replicate(batchSize, 1));
|
||||||
if (!m_useProbsForHiddenReconstruction)
|
if (!m_useProbsForHiddenReconstruction)
|
||||||
{
|
{
|
||||||
sample(v);
|
sample(v);
|
||||||
@@ -367,9 +366,9 @@ public:
|
|||||||
}
|
}
|
||||||
m_w.hiddenBias() += deltaBiasH;
|
m_w.hiddenBias() += deltaBiasH;
|
||||||
|
|
||||||
if (m_w.sigma()[0] > sigmaMin)
|
if (m_sigmas[0] > sigmaMin)
|
||||||
{
|
{
|
||||||
m_w.sigma().array() *= m_sigmaDecay;
|
m_sigmas.array() *= m_sigmaDecay;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_progress += dProgress;
|
m_progress += dProgress;
|
||||||
@@ -395,12 +394,13 @@ public:
|
|||||||
double getEnergy(const VectorXd& visible, const VectorXd& hidden)
|
double getEnergy(const VectorXd& visible, const VectorXd& hidden)
|
||||||
{
|
{
|
||||||
double energy;
|
double energy;
|
||||||
|
double sigma = m_sigmas.array().mean();
|
||||||
|
|
||||||
energy = m_w.visibleBias() * visible;
|
energy = m_w.visibleBias() * visible;
|
||||||
energy += m_w.hiddenBias() * hidden;
|
energy += m_w.hiddenBias() * hidden;
|
||||||
energy += visible.transpose() * m_w.weights() * hidden;
|
energy += visible.transpose() * m_w.weights() * hidden;
|
||||||
|
|
||||||
return -energy/(m_sigma*m_sigma);
|
return -energy/(sigma*sigma);
|
||||||
}
|
}
|
||||||
|
|
||||||
RowVectorXd const & toHidden(const RowVectorXd& v)
|
RowVectorXd const & toHidden(const RowVectorXd& v)
|
||||||
@@ -419,18 +419,23 @@ public:
|
|||||||
|
|
||||||
if (m_useVisibleGaussian)
|
if (m_useVisibleGaussian)
|
||||||
{
|
{
|
||||||
// probsGaussian(v, m_w.sigma());
|
// probsGaussian(v, m_sigmas);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
probsLogistic(m_v, m_w.sigma());
|
probsLogistic(m_v, m_sigmas);
|
||||||
}
|
}
|
||||||
return m_v;
|
return m_v;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setSigma(double value)
|
void setSigma(double value)
|
||||||
{
|
{
|
||||||
m_sigma = value;
|
m_sigmas.fill(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
RowVectorXd& getSigma()
|
||||||
|
{
|
||||||
|
return m_sigmas;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setSigmaDecay(double value)
|
void setSigmaDecay(double value)
|
||||||
@@ -481,10 +486,6 @@ public:
|
|||||||
void setDoLearnVariance(bool flag)
|
void setDoLearnVariance(bool flag)
|
||||||
{
|
{
|
||||||
m_doLearnVariance = flag;
|
m_doLearnVariance = flag;
|
||||||
if (!flag)
|
|
||||||
{
|
|
||||||
m_w.sigma().fill(m_sigma);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setNumGibbs(uint32_t value)
|
void setNumGibbs(uint32_t value)
|
||||||
@@ -517,10 +518,11 @@ private:
|
|||||||
Weights &m_w;
|
Weights &m_w;
|
||||||
RowVectorXd m_h;
|
RowVectorXd m_h;
|
||||||
RowVectorXd m_v;
|
RowVectorXd m_v;
|
||||||
|
RowVectorXd m_sigmas;
|
||||||
|
|
||||||
RbmListener *m_pListener;
|
RbmListener *m_pListener;
|
||||||
noise_gen_t m_noise;
|
noise_gen_t m_noise;
|
||||||
double m_progress;
|
double m_progress;
|
||||||
double m_sigma;
|
|
||||||
double m_sigmaDecay;
|
double m_sigmaDecay;
|
||||||
double m_weightDecay;
|
double m_weightDecay;
|
||||||
double m_lambda;
|
double m_lambda;
|
||||||
|
|||||||
+2
-35
@@ -80,8 +80,6 @@ public:
|
|||||||
m_numHidden = numHidden;
|
m_numHidden = numHidden;
|
||||||
|
|
||||||
m_w.resize(m_numVisible, m_numHidden);
|
m_w.resize(m_numVisible, m_numHidden);
|
||||||
m_sigma.resize(m_numVisible);
|
|
||||||
m_mean.resize(m_numVisible);
|
|
||||||
m_bv.resize(m_numVisible);
|
m_bv.resize(m_numVisible);
|
||||||
m_bh.resize(m_numHidden);
|
m_bh.resize(m_numHidden);
|
||||||
shuffle(1.0);
|
shuffle(1.0);
|
||||||
@@ -92,25 +90,8 @@ public:
|
|||||||
uint32_t i, j;
|
uint32_t i, j;
|
||||||
double kdev = stdDev*sqrt(12.0);
|
double kdev = stdDev*sqrt(12.0);
|
||||||
|
|
||||||
for (i=0; i < m_numVisible; i++)
|
m_bv.array().fill(Noise_Uniform(&m_noise));
|
||||||
{
|
m_bh.array().fill(Noise_Uniform(&m_noise));
|
||||||
m_sigma(i) = 1; //kdev*Noise_Uniform(&m_noise);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i=0; i < m_numVisible; i++)
|
|
||||||
{
|
|
||||||
m_mean(i) = 0; //kdev*Noise_Uniform(&m_noise);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i=0; i < m_numVisible; i++)
|
|
||||||
{
|
|
||||||
m_bv(i) = 0; //kdev*Noise_Uniform(&m_noise);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (j=0; j < m_numHidden; j++)
|
|
||||||
{
|
|
||||||
m_bh(j) = 0; //kdev*Noise_Uniform(&m_noise);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i=0; i < m_numVisible; i++)
|
for (i=0; i < m_numVisible; i++)
|
||||||
{
|
{
|
||||||
@@ -126,8 +107,6 @@ public:
|
|||||||
m_bv = rhs.m_bv;
|
m_bv = rhs.m_bv;
|
||||||
m_bh = rhs.m_bh;
|
m_bh = rhs.m_bh;
|
||||||
m_w = rhs.m_w;
|
m_w = rhs.m_w;
|
||||||
m_sigma = rhs.m_sigma;
|
|
||||||
m_mean = rhs.m_mean;
|
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -142,16 +121,6 @@ public:
|
|||||||
return m_bv;
|
return m_bv;
|
||||||
}
|
}
|
||||||
|
|
||||||
RowVectorXd& sigma()
|
|
||||||
{
|
|
||||||
return m_sigma;
|
|
||||||
}
|
|
||||||
|
|
||||||
RowVectorXd& mean()
|
|
||||||
{
|
|
||||||
return m_mean;
|
|
||||||
}
|
|
||||||
|
|
||||||
RowVectorXd& hiddenBias()
|
RowVectorXd& hiddenBias()
|
||||||
{
|
{
|
||||||
return m_bh;
|
return m_bh;
|
||||||
@@ -294,8 +263,6 @@ private:
|
|||||||
MatrixXd m_w;
|
MatrixXd m_w;
|
||||||
RowVectorXd m_bv;
|
RowVectorXd m_bv;
|
||||||
RowVectorXd m_bh;
|
RowVectorXd m_bh;
|
||||||
RowVectorXd m_sigma;
|
|
||||||
RowVectorXd m_mean;
|
|
||||||
|
|
||||||
void free()
|
void free()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user