From 24f253e892f36872365a5994f25e59d6b99f8fb6 Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Tue, 12 Nov 2019 23:00:55 +0000 Subject: [PATCH] - fixed crash, when try to train without training patterns git-svn-id: http://moon:8086/svn/software/trunk/projects/Rbm@664 b431acfa-c32f-4a4a-93f1-934dc6c82436 --- source/Layer.hpp | 5 ++++- source/MainComponent.cpp | 5 ++++- source/Stack.cpp | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/source/Layer.hpp b/source/Layer.hpp index 4837847..b39a6f4 100644 --- a/source/Layer.hpp +++ b/source/Layer.hpp @@ -36,7 +36,10 @@ public: void train(arma::mat const &batch, IListener *pListener=nullptr) { - Rbm::train(trainingData(batch), pListener); + if (batch.n_rows > 0) + { + Rbm::train(trainingData(batch), pListener); + } } std::string& name() diff --git a/source/MainComponent.cpp b/source/MainComponent.cpp index eaedd52..2017d77 100644 --- a/source/MainComponent.cpp +++ b/source/MainComponent.cpp @@ -762,7 +762,10 @@ void MainComponent::comboBoxChanged (ComboBox* comboBoxThatHasChanged) m_pLayer = static_cast(m_stack->getLayer(index)); updateControls(); m_pLayer->redrawWeights(m_weightIndex); - m_pLayer->setTrainingData(m_stack->trainingData().row(m_trainingIndex)); + if (m_stack->trainingData().n_rows > 0) + { + m_pLayer->setTrainingData(m_stack->trainingData().row(m_trainingIndex)); + } //[/UserComboBoxCode_m_rbmSelect] } diff --git a/source/Stack.cpp b/source/Stack.cpp index 47b2482..c6850e9 100644 --- a/source/Stack.cpp +++ b/source/Stack.cpp @@ -198,7 +198,7 @@ void Stack::train(Rbm::IListener* pListener) while(pLayer) { std::cout << m_name << ": " << " Training of layer " << std::to_string(pLayer->id()) << std::endl; - pLayer->train(trainingData(pLayer), pListener); + pLayer->train(m_trainingData, pListener); pLayer = pLayer->next; } }