- refactored
git-svn-id: http://moon:8086/svn/software/trunk/projects/Rbm@824 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
+33
-8
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user