deeplearning4j - 如何在 deeplearning4j 中存储和加载经过训练的数据?
问题描述
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());
解决方案
你可以像这样写/读它
ModelSerializer.writeModel(modelToSave, "location", true);
...
MultiLayerNetwork model = ModelSerializer.restoreMultiLayerNetwork("location");
推荐阅读
- amazon-web-services - 本地 kibana AWS 签名 v4
- python-3.x - 循环时Python3缺少异常
- asp.net - 生成的链接上的 ASP.net 身份验证
- android - 为什么我的 Preferences 类中的文本被删掉了?
- nginx - nginx ldap auth 和 CoreOS Dex 的区别
- typescript - 如何使用 Typescript 的 Enum 指定 lodash.groupBy 的返回类型?
- r - 使用自适应窗口长度计算 data.table 中的滚动平均值
- swagger-codegen - 如何引用 OpenAPI Generator 任务属性
- datagridview - 如何在 dataGridView1_Scroll 事件中获取第一个可见的 columnindex
- javascript - 为每个单独的按钮提供正确的名称