diff --git a/Source/RbmComponent.cpp b/Source/RbmComponent.cpp index f1eb363..87acd6c 100644 --- a/Source/RbmComponent.cpp +++ b/Source/RbmComponent.cpp @@ -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] diff --git a/Source/RbmComponent.h b/Source/RbmComponent.h index 46a7f04..286e376 100644 --- a/Source/RbmComponent.h +++ b/Source/RbmComponent.h @@ -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.