Search in sources :

Example 76 with ScoreIterationListener

use of org.deeplearning4j.optimize.listeners.ScoreIterationListener in project deeplearning4j by deeplearning4j.

the class TestFlowListener method testUI.

@Test
public void testUI() throws Exception {
    // Number of input channels
    int nChannels = 1;
    // The number of possible outcomes
    int outputNum = 10;
    // Test batch size
    int batchSize = 64;
    DataSetIterator mnistTrain = new MnistDataSetIterator(batchSize, true, 12345);
    MultiLayerConfiguration conf = // Training iterations as above
    new NeuralNetConfiguration.Builder().seed(12345).iterations(1).regularization(true).l2(0.0005).learningRate(0.01).weightInit(WeightInit.XAVIER).optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).updater(Updater.NESTEROVS).momentum(0.9).list().layer(0, new ConvolutionLayer.Builder(5, 5).nIn(nChannels).stride(1, 1).nOut(20).activation(Activation.IDENTITY).build()).layer(1, new SubsamplingLayer.Builder(SubsamplingLayer.PoolingType.MAX).kernelSize(2, 2).stride(2, 2).build()).layer(2, new ConvolutionLayer.Builder(5, 5).stride(1, 1).nOut(50).activation(Activation.IDENTITY).build()).layer(3, new SubsamplingLayer.Builder(SubsamplingLayer.PoolingType.MAX).kernelSize(2, 2).stride(2, 2).build()).layer(4, new DenseLayer.Builder().activation(Activation.RELU).nOut(500).build()).layer(5, new OutputLayer.Builder(LossFunctions.LossFunction.NEGATIVELOGLIKELIHOOD).nOut(outputNum).activation(Activation.SOFTMAX).build()).setInputType(//See note below
    InputType.convolutionalFlat(28, 28, 1)).backprop(true).pretrain(false).build();
    MultiLayerNetwork net = new MultiLayerNetwork(conf);
    net.init();
    net.setListeners(new FlowIterationListener(1), new ScoreIterationListener(1));
    for (int i = 0; i < 50; i++) {
        net.fit(mnistTrain.next());
        Thread.sleep(1000);
    }
    Thread.sleep(100000);
}
Also used : MultiLayerConfiguration(org.deeplearning4j.nn.conf.MultiLayerConfiguration) MnistDataSetIterator(org.deeplearning4j.datasets.iterator.impl.MnistDataSetIterator) DenseLayer(org.deeplearning4j.nn.conf.layers.DenseLayer) MultiLayerNetwork(org.deeplearning4j.nn.multilayer.MultiLayerNetwork) ScoreIterationListener(org.deeplearning4j.optimize.listeners.ScoreIterationListener) DataSetIterator(org.nd4j.linalg.dataset.api.iterator.DataSetIterator) MnistDataSetIterator(org.deeplearning4j.datasets.iterator.impl.MnistDataSetIterator) ConvolutionLayer(org.deeplearning4j.nn.conf.layers.ConvolutionLayer) Test(org.junit.Test)

Aggregations

ScoreIterationListener (org.deeplearning4j.optimize.listeners.ScoreIterationListener)76 Test (org.junit.Test)75 DataSetIterator (org.nd4j.linalg.dataset.api.iterator.DataSetIterator)44 NeuralNetConfiguration (org.deeplearning4j.nn.conf.NeuralNetConfiguration)43 MultiLayerNetwork (org.deeplearning4j.nn.multilayer.MultiLayerNetwork)41 IrisDataSetIterator (org.deeplearning4j.datasets.iterator.impl.IrisDataSetIterator)39 DataSet (org.nd4j.linalg.dataset.DataSet)37 MultiLayerConfiguration (org.deeplearning4j.nn.conf.MultiLayerConfiguration)35 InMemoryModelSaver (org.deeplearning4j.earlystopping.saver.InMemoryModelSaver)26 MaxEpochsTerminationCondition (org.deeplearning4j.earlystopping.termination.MaxEpochsTerminationCondition)26 INDArray (org.nd4j.linalg.api.ndarray.INDArray)23 MaxTimeIterationTerminationCondition (org.deeplearning4j.earlystopping.termination.MaxTimeIterationTerminationCondition)22 OutputLayer (org.deeplearning4j.nn.conf.layers.OutputLayer)21 ComputationGraphConfiguration (org.deeplearning4j.nn.conf.ComputationGraphConfiguration)17 ComputationGraph (org.deeplearning4j.nn.graph.ComputationGraph)17 IterationListener (org.deeplearning4j.optimize.api.IterationListener)15 MnistDataSetIterator (org.deeplearning4j.datasets.iterator.impl.MnistDataSetIterator)13 MaxScoreIterationTerminationCondition (org.deeplearning4j.earlystopping.termination.MaxScoreIterationTerminationCondition)13 IEarlyStoppingTrainer (org.deeplearning4j.earlystopping.trainer.IEarlyStoppingTrainer)13 EarlyStoppingConfiguration (org.deeplearning4j.earlystopping.EarlyStoppingConfiguration)12