diff --git a/source/AStack.cpp b/source/AStack.cpp index bb6ea46..21407d1 100644 --- a/source/AStack.cpp +++ b/source/AStack.cpp @@ -26,10 +26,6 @@ AStack::AStack(StackType type, const std::string &name) { } -AStack::AStack(const AStack& orig) -{ -} - AStack::~AStack() { Layer *pLayer = m_pLayers; @@ -41,39 +37,6 @@ AStack::~AStack() } } -AStack::AStack(StackType type, const std::string &name, Json::Value& layers, LayerConstructor* pLayerConstructor) -: m_type(type) -, m_name(name) -, m_pLayers(nullptr) -{ - for (int i=0; i < layers.size(); i++) - { - Json::Value &layer = layers[i]; - - string layername = layer["name"].asString(); - int numVisibleX = layer["numVisibleX"].asInt(); - int numVisibleY = layer["numVisibleY"].asInt(); - int numHidden = layer["numHidden"].asInt(); - int numContext = layer["numContext"].asInt(); - - Layer *pLayer = nullptr; - if (!pLayerConstructor) - { - pLayer = new Layer(layername, i, numVisibleX, numVisibleY, numHidden, numContext); - } - else - { - pLayer = pLayerConstructor->onConstruct(this, layername, i, numVisibleX, numVisibleY, numHidden, numContext); - } - - assert(pLayer != nullptr); - - pLayer->fromJson(layer["rbm"]); - addLayer(pLayer); - } - -} - AStack::StackType AStack::type() { return m_type; diff --git a/source/AStack.hpp b/source/AStack.hpp index 80815b2..0b95715 100644 --- a/source/AStack.hpp +++ b/source/AStack.hpp @@ -48,8 +48,7 @@ public: static const char *stackTypeStrings[NUM_STACKTYPES]; AStack(StackType type, const std::string &name); - AStack(StackType type, const std::string &name, Json::Value &layers, LayerConstructor *pLayerConstructor=nullptr); - AStack(const AStack& orig); + AStack(const AStack& orig) = delete; virtual ~AStack(); StackType type(); diff --git a/source/DeepStack.cpp b/source/DeepStack.cpp index 602ee75..8b54d2e 100644 --- a/source/DeepStack.cpp +++ b/source/DeepStack.cpp @@ -20,12 +20,6 @@ DeepStack::DeepStack(const std::string &name) { } -DeepStack::DeepStack(const std::string &name, Json::Value& layers, LayerConstructor* pLayerConstructor) -: AStack(StackType::Deep, name, layers, pLayerConstructor) -{ - -} - DeepStack::~DeepStack() { } diff --git a/source/DeepStack.hpp b/source/DeepStack.hpp index af15f26..99e3373 100644 --- a/source/DeepStack.hpp +++ b/source/DeepStack.hpp @@ -25,7 +25,6 @@ class DeepStack : public AStack { public: DeepStack(const std::string &name); - DeepStack(const std::string &name, Json::Value &layers, LayerConstructor *pLayerConstructor=nullptr); DeepStack(const DeepStack& orig) = delete; virtual ~DeepStack(); diff --git a/source/MainComponent.cpp b/source/MainComponent.cpp index 85b108d..629b248 100644 --- a/source/MainComponent.cpp +++ b/source/MainComponent.cpp @@ -587,7 +587,6 @@ void MainComponent::buttonClicked (Button* buttonThatWasClicked) projectNameLabel->setText(m_file.getFileNameWithoutExtension(), NotificationType::dontSendNotification); AStack *pStack = StackCreator::fromFile(m_file.getParentDirectory().getFullPathName().toStdString(), std::string(projectNameLabel->getText().getCharPointer()), this); m_stack = reinterpret_cast(pStack); - // m_stack->load(this); m_stack->loadWeights(m_dir); m_rbmSelect->clear(dontSendNotification); diff --git a/source/RnnStack.cpp b/source/RnnStack.cpp index 6bf4bdb..ffe7ac6 100644 --- a/source/RnnStack.cpp +++ b/source/RnnStack.cpp @@ -18,12 +18,6 @@ RnnStack::RnnStack(const std::string &name) { } -RnnStack::RnnStack(const std::string &name, Json::Value& layers, LayerConstructor* pLayerConstructor) -: AStack(StackType::Rnn, name, layers, pLayerConstructor) -{ - -} - RnnStack::~RnnStack() { } diff --git a/source/RnnStack.hpp b/source/RnnStack.hpp index 6bdc7b5..61d26c0 100644 --- a/source/RnnStack.hpp +++ b/source/RnnStack.hpp @@ -20,7 +20,6 @@ class RnnStack : public AStack { public: RnnStack(const std::string &name); - RnnStack(const std::string &name, Json::Value &layers, LayerConstructor *pLayerConstructor=nullptr); RnnStack(const RnnStack& orig) = delete; virtual ~RnnStack(); diff --git a/source/StackCreator.cpp b/source/StackCreator.cpp index a23e2d9..cf04b57 100644 --- a/source/StackCreator.cpp +++ b/source/StackCreator.cpp @@ -35,18 +35,43 @@ AStack* StackCreator::fromJson(Json::Value& project, LayerConstructor *pLayerCon Json::Value &layers = project["stack"]["layers"]; int type = stack["type"].asInt(); - if (type == AStack::StackType::Deep) - { - return new DeepStack(name, layers, pLayerConstructor); - } - + AStack *pStack = nullptr; if (type == AStack::StackType::Rnn) { - return new RnnStack(name, layers, pLayerConstructor); + pStack = new RnnStack(name); + } + else + { + pStack = new DeepStack(name); } - return new DeepStack(name, layers, pLayerConstructor); - + for (int i=0; i < layers.size(); i++) + { + Json::Value &layer = layers[i]; + + string layername = layer["name"].asString(); + int numVisibleX = layer["numVisibleX"].asInt(); + int numVisibleY = layer["numVisibleY"].asInt(); + int numHidden = layer["numHidden"].asInt(); + int numContext = layer["numContext"].asInt(); + + Layer *pLayer = nullptr; + if (!pLayerConstructor) + { + pLayer = new Layer(layername, i, numVisibleX, numVisibleY, numHidden, numContext); + } + else + { + pLayer = pLayerConstructor->onConstruct(pStack, layername, i, numVisibleX, numVisibleY, numHidden, numContext); + } + + assert(pLayer != nullptr); + + pLayer->fromJson(layer["rbm"]); + pStack->addLayer(pLayer); + } + + return pStack; } AStack* StackCreator::fromFile(const std::string &dir, const std::string &name, LayerConstructor *pLayerConstructor)