【问题标题】:How do i store and load trained data in deeplearning4j?如何在 deeplearning4j 中存储和加载经过训练的数据?
【发布时间】:2018-12-19 23:26:42
【问题描述】:

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());    

【问题讨论】:

    标签: deeplearning4j


    【解决方案1】:

    ModelSerializer

    你可以这样写/读它

    ModelSerializer.writeModel(modelToSave, "location", true);
    
    ...
    
    MultiLayerNetwork model = ModelSerializer.restoreMultiLayerNetwork("location");
    

    【讨论】:

      猜你喜欢
      • 2016-09-03
      • 2015-10-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-16
      • 2018-04-21
      • 2017-07-28
      相关资源
      最近更新 更多