本文整理汇总了Java中org.deeplearning4j.eval.Evaluation.Metric方法的典型用法代码示例。如果您正苦于以下问题:Java Evaluation.Metric方法的具体用法?Java Evaluation.Metric怎么用?Java Evaluation.Metric使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.deeplearning4j.eval.Evaluation
的用法示例。
在下文中一共展示了Evaluation.Metric方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testClassificationScoreFunctionSimple
import org.deeplearning4j.eval.Evaluation; //导入方法依赖的package包/类
@Test
public void testClassificationScoreFunctionSimple() throws Exception {
for(Evaluation.Metric metric : Evaluation.Metric.values()) {
log.info("Metric: " + metric);
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
.list()
.layer(new DenseLayer.Builder().nIn(784).nOut(32).build())
.layer(new OutputLayer.Builder().nIn(32).nOut(10).activation(Activation.SOFTMAX).build())
.build();
MultiLayerNetwork net = new MultiLayerNetwork(conf);
net.init();
DataSetIterator iter = new MnistDataSetIterator(32, false, 12345);
List<DataSet> l = new ArrayList<>();
for( int i=0; i<10; i++ ){
DataSet ds = iter.next();
l.add(ds);
}
iter = new ExistingDataSetIterator(l);
EarlyStoppingModelSaver<MultiLayerNetwork> saver = new InMemoryModelSaver<>();
EarlyStoppingConfiguration<MultiLayerNetwork> esConf =
new EarlyStoppingConfiguration.Builder<MultiLayerNetwork>()
.epochTerminationConditions(new MaxEpochsTerminationCondition(5))
.iterationTerminationConditions(
new MaxTimeIterationTerminationCondition(1, TimeUnit.MINUTES))
.scoreCalculator(new ClassificationScoreCalculator(metric, iter)).modelSaver(saver)
.build();
EarlyStoppingTrainer trainer = new EarlyStoppingTrainer(esConf, net, iter);
EarlyStoppingResult<MultiLayerNetwork> result = trainer.fit();
assertNotNull(result.getBestModel());
}
}
示例2: ClassificationScoreCalculator
import org.deeplearning4j.eval.Evaluation; //导入方法依赖的package包/类
public ClassificationScoreCalculator(Evaluation.Metric metric, DataSetIterator iterator){
super(iterator);
this.metric = metric;
}
示例3: testClassificationScoreFunctionSimple
import org.deeplearning4j.eval.Evaluation; //导入方法依赖的package包/类
@Test
public void testClassificationScoreFunctionSimple() throws Exception {
for(Evaluation.Metric metric : Evaluation.Metric.values()) {
log.info("Metric: " + metric);
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder()
.graphBuilder()
.addInputs("in")
.layer("0", new DenseLayer.Builder().nIn(784).nOut(32).build(), "in")
.layer("1", new OutputLayer.Builder().nIn(32).nOut(10).activation(Activation.SOFTMAX).build(), "0")
.setOutputs("1")
.build();
ComputationGraph net = new ComputationGraph(conf);
net.init();
DataSetIterator iter = new MnistDataSetIterator(32, false, 12345);
List<DataSet> l = new ArrayList<>();
for( int i=0; i<10; i++ ){
DataSet ds = iter.next();
l.add(ds);
}
iter = new ExistingDataSetIterator(l);
EarlyStoppingModelSaver<ComputationGraph> saver = new InMemoryModelSaver<>();
EarlyStoppingConfiguration<ComputationGraph> esConf =
new EarlyStoppingConfiguration.Builder<ComputationGraph>()
.epochTerminationConditions(new MaxEpochsTerminationCondition(5))
.iterationTerminationConditions(
new MaxTimeIterationTerminationCondition(1, TimeUnit.MINUTES))
.scoreCalculator(new ClassificationScoreCalculator(metric, iter)).modelSaver(saver)
.build();
EarlyStoppingGraphTrainer trainer = new EarlyStoppingGraphTrainer(esConf, net, iter);
EarlyStoppingResult<ComputationGraph> result = trainer.fit();
assertNotNull(result.getBestModel());
}
}