[RBM]
- improved multi layer weight reconstruction using weight convolution git-svn-id: http://moon:8086/svn/software/trunk/projects/RBM@306 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
+9
-21
@@ -286,38 +286,22 @@ void RbmComponent::redrawReconstruction()
|
|||||||
DrawReconstruction->DrawData();
|
DrawReconstruction->DrawData();
|
||||||
}
|
}
|
||||||
|
|
||||||
MatrixXd RbmComponent::getAccumulatedWeight(RowVectorXd const &h)
|
MatrixXd RbmComponent::getConvolutedWeight(RowVectorXd const &w)
|
||||||
{
|
{
|
||||||
if (upper)
|
if (upper)
|
||||||
{
|
{
|
||||||
RowVectorXd v(m_weights.getNumVisible());
|
MatrixXd wc = w * upper->getWeights().transpose() * 1.0/sqrt((double)w.cols());
|
||||||
toVisible(v, h);
|
return upper->getConvolutedWeight(wc);
|
||||||
return upper->getAccumulatedWeight(v);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MatrixXd w = h * m_weights.weights().transpose();
|
|
||||||
// cout << "w=" << endl;
|
|
||||||
// cout << w << endl;
|
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
void RbmComponent::redrawWeights()
|
void RbmComponent::redrawWeights()
|
||||||
{
|
{
|
||||||
if (upper)
|
DrawWeights->getData() = getConvolutedWeight(m_weights.weights().col(m_currWeightIndexToDraw));
|
||||||
{
|
|
||||||
RowVectorXd h = RowVectorXd::Zero(m_weights.getNumHidden());
|
|
||||||
h(m_currWeightIndexToDraw) = 1.0;
|
|
||||||
DrawWeights->getData() = getAccumulatedWeight(h);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
RowVectorXd w = m_weights.weights().col(m_currWeightIndexToDraw);
|
|
||||||
// cout << "w=" << endl;
|
|
||||||
// cout << w << endl;
|
|
||||||
DrawWeights->getData() = w;
|
|
||||||
}
|
|
||||||
DrawWeights->DrawData();
|
DrawWeights->DrawData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -388,7 +372,11 @@ Weights& RbmComponent::getTopWeights()
|
|||||||
{
|
{
|
||||||
return m_weights;
|
return m_weights;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MatrixXd const& RbmComponent::getWeights()
|
||||||
|
{
|
||||||
|
return m_weights.weights();
|
||||||
}
|
}
|
||||||
//[/MiscUserCode]
|
//[/MiscUserCode]
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,8 @@ public:
|
|||||||
pObj->upper = this;
|
pObj->upper = this;
|
||||||
}
|
}
|
||||||
virtual Weights& getTopWeights() = 0;
|
virtual Weights& getTopWeights() = 0;
|
||||||
virtual MatrixXd getAccumulatedWeight(RowVectorXd const &h) = 0;
|
virtual MatrixXd getConvolutedWeight(RowVectorXd const &h) = 0;
|
||||||
|
virtual MatrixXd const& getWeights() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class RbmComponentListener
|
class RbmComponentListener
|
||||||
@@ -132,7 +133,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
Weights& getTopWeights() override;
|
Weights& getTopWeights() override;
|
||||||
MatrixXd getAccumulatedWeight(RowVectorXd const &h) override;
|
MatrixXd getConvolutedWeight(RowVectorXd const &h) override;
|
||||||
|
MatrixXd const& getWeights() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//[UserVariables] -- You can add your own custom variables in this section.
|
//[UserVariables] -- You can add your own custom variables in this section.
|
||||||
|
|||||||
Reference in New Issue
Block a user