[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();
|
||||
}
|
||||
|
||||
MatrixXd RbmComponent::getAccumulatedWeight(RowVectorXd const &h)
|
||||
MatrixXd RbmComponent::getConvolutedWeight(RowVectorXd const &w)
|
||||
{
|
||||
if (upper)
|
||||
{
|
||||
RowVectorXd v(m_weights.getNumVisible());
|
||||
toVisible(v, h);
|
||||
return upper->getAccumulatedWeight(v);
|
||||
MatrixXd wc = w * upper->getWeights().transpose() * 1.0/sqrt((double)w.cols());
|
||||
return upper->getConvolutedWeight(wc);
|
||||
}
|
||||
else
|
||||
{
|
||||
MatrixXd w = h * m_weights.weights().transpose();
|
||||
// cout << "w=" << endl;
|
||||
// cout << w << endl;
|
||||
return w;
|
||||
}
|
||||
|
||||
}
|
||||
void RbmComponent::redrawWeights()
|
||||
{
|
||||
if (upper)
|
||||
{
|
||||
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->getData() = getConvolutedWeight(m_weights.weights().col(m_currWeightIndexToDraw));
|
||||
DrawWeights->DrawData();
|
||||
}
|
||||
|
||||
@@ -388,7 +372,11 @@ Weights& RbmComponent::getTopWeights()
|
||||
{
|
||||
return m_weights;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
MatrixXd const& RbmComponent::getWeights()
|
||||
{
|
||||
return m_weights.weights();
|
||||
}
|
||||
//[/MiscUserCode]
|
||||
|
||||
|
||||
@@ -50,7 +50,8 @@ public:
|
||||
pObj->upper = this;
|
||||
}
|
||||
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
|
||||
@@ -132,7 +133,8 @@ public:
|
||||
}
|
||||
|
||||
Weights& getTopWeights() override;
|
||||
MatrixXd getAccumulatedWeight(RowVectorXd const &h) override;
|
||||
MatrixXd getConvolutedWeight(RowVectorXd const &h) override;
|
||||
MatrixXd const& getWeights() override;
|
||||
|
||||
private:
|
||||
//[UserVariables] -- You can add your own custom variables in this section.
|
||||
|
||||
Reference in New Issue
Block a user