use of org.deeplearning4j.optimize.listeners.ScoreIterationListener in project deeplearning4j by deeplearning4j.
the class BackPropMLPTest method testMLPTrivial.
@Test
public void testMLPTrivial() {
//Simplest possible case: 1 hidden layer, 1 hidden neuron, batch size of 1.
MultiLayerNetwork network = new MultiLayerNetwork(getIrisMLPSimpleConfig(new int[] { 1 }, Activation.SIGMOID));
network.setListeners(new ScoreIterationListener(1));
network.init();
DataSetIterator iter = new IrisDataSetIterator(1, 10);
while (iter.hasNext()) network.fit(iter.next());
}
use of org.deeplearning4j.optimize.listeners.ScoreIterationListener in project deeplearning4j by deeplearning4j.
the class GravesLSTMOutputTest method testSameLabelsOutputWithTBPTT.
@Test
public void testSameLabelsOutputWithTBPTT() {
MultiLayerNetwork network = new MultiLayerNetwork(getNetworkConf(40, true));
network.init();
network.setListeners(new ScoreIterationListener(1));
for (int i = 0; i < window / 100; i++) {
INDArray d = data.get(NDArrayIndex.interval(100 * i, 100 * (i + 1)), NDArrayIndex.all());
network.fit(reshapeInput(d.dup()), reshapeInput(d.dup()));
}
Evaluation ev = eval(network);
}
use of org.deeplearning4j.optimize.listeners.ScoreIterationListener in project deeplearning4j by deeplearning4j.
the class BackTrackLineSearchTest method testBackTrackLineLBFGS.
@Test
public void testBackTrackLineLBFGS() {
OptimizationAlgorithm optimizer = OptimizationAlgorithm.LBFGS;
DataSet data = irisIter.next();
data.normalizeZeroMeanZeroUnitVariance();
MultiLayerNetwork network = new MultiLayerNetwork(getIrisMultiLayerConfig(Activation.RELU, 5, optimizer));
network.init();
IterationListener listener = new ScoreIterationListener(1);
network.setListeners(Collections.singletonList(listener));
double oldScore = network.score(data);
network.fit(data.getFeatureMatrix(), data.getLabels());
double score = network.score();
assertTrue(score < oldScore);
}
use of org.deeplearning4j.optimize.listeners.ScoreIterationListener in project deeplearning4j by deeplearning4j.
the class BackTrackLineSearchTest method testBackTrackLineHessian.
@Test(expected = Exception.class)
public void testBackTrackLineHessian() {
OptimizationAlgorithm optimizer = OptimizationAlgorithm.HESSIAN_FREE;
DataSet data = irisIter.next();
MultiLayerNetwork network = new MultiLayerNetwork(getIrisMultiLayerConfig(Activation.RELU, 100, optimizer));
network.init();
IterationListener listener = new ScoreIterationListener(1);
network.setListeners(Collections.singletonList(listener));
network.fit(data.getFeatureMatrix(), data.getLabels());
}
use of org.deeplearning4j.optimize.listeners.ScoreIterationListener in project deeplearning4j by deeplearning4j.
the class TestPlayUI method testUIMultipleSessions.
@Test
@Ignore
public void testUIMultipleSessions() throws Exception {
for (int session = 0; session < 3; session++) {
StatsStorage ss = new InMemoryStatsStorage();
UIServer uiServer = UIServer.getInstance();
uiServer.attach(ss);
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).iterations(1).list().layer(0, new DenseLayer.Builder().activation(Activation.TANH).nIn(4).nOut(4).build()).layer(1, new OutputLayer.Builder().lossFunction(LossFunctions.LossFunction.MCXENT).activation(Activation.SOFTMAX).nIn(4).nOut(3).build()).pretrain(false).backprop(true).build();
MultiLayerNetwork net = new MultiLayerNetwork(conf);
net.init();
net.setListeners(new StatsListener(ss), new ScoreIterationListener(1));
DataSetIterator iter = new IrisDataSetIterator(150, 150);
for (int i = 0; i < 20; i++) {
net.fit(iter);
Thread.sleep(100);
}
}
Thread.sleep(1000000);
}
Aggregations