diff --git a/source/DrawComponent.cpp b/source/DrawComponent.cpp index b346c4d..e828773 100644 --- a/source/DrawComponent.cpp +++ b/source/DrawComponent.cpp @@ -227,6 +227,11 @@ arma::mat& DrawComponent::getData () void DrawComponent::DrawData () { + if (m_data.n_elem == 0) + { + return; + } + double max = arma::abs(m_data).max(); if (max < 1.0) diff --git a/source/Rbm.cpp b/source/Rbm.cpp index 872fcaf..72ab58a 100644 --- a/source/Rbm.cpp +++ b/source/Rbm.cpp @@ -320,6 +320,10 @@ arma::mat Rbm::vc_to_v(const arma::mat &vc) const arma::mat Rbm::vc_to_c(const arma::mat &vc) const { + if (numContext() == 0) + { + return arma::mat(1,0); + } return vc.submat(0, numVisible() - numContext(), 0, numVisible() - 1); } diff --git a/source/RbmComponent.cpp b/source/RbmComponent.cpp index 3d0d61c..176d655 100644 --- a/source/RbmComponent.cpp +++ b/source/RbmComponent.cpp @@ -40,14 +40,11 @@ RbmComponent::RbmComponent (const std::string &name, size_t id, size_t numVisibl addAndMakeVisible (DrawHidden = new DrawComponent (numHidden, 1)); DrawHidden->setListener(this); - if (numContext) - { - addAndMakeVisible (DrawContextTrain = new DrawComponent (numContext, 1)); - DrawContextTrain->setListener(this); + addAndMakeVisible (DrawContextTrain = new DrawComponent (numContext, 1)); + DrawContextTrain->setListener(this); - addAndMakeVisible (DrawContextReconst = new DrawComponent (numContext, 1)); - DrawContextReconst->setListener(this); - } + addAndMakeVisible (DrawContextReconst = new DrawComponent (numContext, 1)); + DrawContextReconst->setListener(this); addAndMakeVisible (DrawVisibleReconst = new DrawComponent (numVisibleX, numVisibleY)); addAndMakeVisible (DrawWeights = new DrawComponent (numVisibleX, numVisibleY, 0.5, 0.5)); @@ -146,14 +143,8 @@ void RbmComponent::resized() DrawVisibleTrain->setBoundsRelative(0, 0, 100./m_sizeX, 100./m_sizeY); DrawVisibleReconst->setBoundsRelative(110./m_sizeX, 0, 100./m_sizeX, 100./m_sizeY); DrawWeights->setBoundsRelative (220./m_sizeX, 0, 100./m_sizeX, 100./m_sizeY); - if (DrawContextTrain) - { - DrawContextTrain->setBoundsRelative (0, 110./m_sizeY, 430./m_sizeX, 20./m_sizeY); - } - if (DrawContextReconst) - { - DrawContextReconst->setBoundsRelative (0, 140./m_sizeY, 430./m_sizeX, 20./m_sizeY); - } + DrawContextTrain->setBoundsRelative (0, 110./m_sizeY, 430./m_sizeX, 20./m_sizeY); + DrawContextReconst->setBoundsRelative (0, 140./m_sizeY, 430./m_sizeX, 20./m_sizeY); DrawHidden->setBoundsRelative (0, 170./m_sizeY, 430./m_sizeX, 20./m_sizeY); m_toggleEnable->setBoundsRelative (330./m_sizeX, 0, 80./m_sizeX, 24./m_sizeY); }