deeplearning4j:如何在持久性级别上存储/保存训练好的模型并将其加载回临时评估深度学习模型的请求中?
DataNormalization normalizer = new NormalizerStandardize();
normalizer.fit(trainingData); //Collect the statistics (mean/stdev) from the training data. This does not modify the input data
normalizer.transform(trainingData);
//run the model
MultiLayerNetwork model = new MultiLayerNetwork(conf);
model.init();
model.setListeners(new ScoreIterationListener(100));
for( int i=0; i<epochs; i++ ) {
model.fit(trainingData);
}
我需要存储经过训练的模型。我怎样才能做到这一点?与哪个Api?
//evaluate the model on the test set
Evaluation eval = new Evaluation(3);
INDArray output = model.output(testData.getFeatures());
eval.eval(testData.getLabels(), output);
log.info(eval.stats());
答案 0 :(得分:0)
您可以这样编写/阅读它
ModelSerializer.writeModel(modelToSave, "location", true);
...
MultiLayerNetwork model = ModelSerializer.restoreMultiLayerNetwork("location");