Search in sources :

Example 81 with MultiLayerNetwork

use of org.deeplearning4j.nn.multilayer.MultiLayerNetwork in project deeplearning4j by deeplearning4j.

the class LayerConfigTest method testLearningRatePolicyNone.

@Test
public void testLearningRatePolicyNone() {
    double lr = 2;
    MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().learningRate(lr).learningRateDecayPolicy(LearningRatePolicy.None).list().layer(0, new DenseLayer.Builder().nIn(2).nOut(2).build()).layer(1, new DenseLayer.Builder().nIn(2).nOut(2).build()).build();
    MultiLayerNetwork net = new MultiLayerNetwork(conf);
    net.init();
    assertEquals(LearningRatePolicy.None, conf.getConf(0).getLearningRatePolicy());
    assertEquals(LearningRatePolicy.None, conf.getConf(1).getLearningRatePolicy());
}
Also used : MultiLayerNetwork(org.deeplearning4j.nn.multilayer.MultiLayerNetwork) Test(org.junit.Test)

Example 82 with MultiLayerNetwork

use of org.deeplearning4j.nn.multilayer.MultiLayerNetwork in project deeplearning4j by deeplearning4j.

the class LayerConfigTest method testLayerName.

@Test
public void testLayerName() {
    String name1 = "genisys";
    String name2 = "bill";
    MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().list().layer(0, new DenseLayer.Builder().nIn(2).nOut(2).name(name1).build()).layer(1, new DenseLayer.Builder().nIn(2).nOut(2).name(name2).build()).build();
    MultiLayerNetwork net = new MultiLayerNetwork(conf);
    net.init();
    assertEquals(name1, conf.getConf(0).getLayer().getLayerName().toString());
    assertEquals(name2, conf.getConf(1).getLayer().getLayerName().toString());
}
Also used : MultiLayerNetwork(org.deeplearning4j.nn.multilayer.MultiLayerNetwork) Test(org.junit.Test)

Example 83 with MultiLayerNetwork

use of org.deeplearning4j.nn.multilayer.MultiLayerNetwork in project deeplearning4j by deeplearning4j.

the class LayerConfigTest method testLearningRatePolicySigmoid.

@Test
public void testLearningRatePolicySigmoid() {
    double lr = 2;
    double lrDecayRate = 5;
    double steps = 4;
    int iterations = 1;
    MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().iterations(iterations).learningRate(lr).learningRateDecayPolicy(LearningRatePolicy.Sigmoid).lrPolicyDecayRate(lrDecayRate).lrPolicySteps(steps).list().layer(0, new DenseLayer.Builder().nIn(2).nOut(2).build()).layer(1, new DenseLayer.Builder().nIn(2).nOut(2).build()).build();
    MultiLayerNetwork net = new MultiLayerNetwork(conf);
    net.init();
    assertEquals(LearningRatePolicy.Sigmoid, conf.getConf(0).getLearningRatePolicy());
    assertEquals(LearningRatePolicy.Sigmoid, conf.getConf(1).getLearningRatePolicy());
    assertEquals(lrDecayRate, conf.getConf(0).getLrPolicyDecayRate(), 0.0);
    assertEquals(lrDecayRate, conf.getConf(1).getLrPolicyDecayRate(), 0.0);
    assertEquals(steps, conf.getConf(0).getLrPolicySteps(), 0.0);
    assertEquals(steps, conf.getConf(1).getLrPolicySteps(), 0.0);
}
Also used : MultiLayerNetwork(org.deeplearning4j.nn.multilayer.MultiLayerNetwork) Test(org.junit.Test)

Example 84 with MultiLayerNetwork

use of org.deeplearning4j.nn.multilayer.MultiLayerNetwork in project deeplearning4j by deeplearning4j.

the class LayerConfigTest method testUpdaterRhoRmsDecayLayerwiseOverride.

@Test
public void testUpdaterRhoRmsDecayLayerwiseOverride() {
    MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().updater(Updater.ADADELTA).rho(0.5).list().layer(0, new DenseLayer.Builder().nIn(2).nOut(2).build()).layer(1, new DenseLayer.Builder().nIn(2).nOut(2).rho(0.01).build()).build();
    MultiLayerNetwork net = new MultiLayerNetwork(conf);
    net.init();
    assertEquals("ADADELTA", conf.getConf(0).getLayer().getUpdater().toString());
    assertEquals("ADADELTA", conf.getConf(1).getLayer().getUpdater().toString());
    assertEquals(0.5, conf.getConf(0).getLayer().getRho(), 0.0);
    assertEquals(0.01, conf.getConf(1).getLayer().getRho(), 0.0);
    conf = new NeuralNetConfiguration.Builder().updater(Updater.RMSPROP).rmsDecay(2.0).list().layer(0, new DenseLayer.Builder().nIn(2).nOut(2).rmsDecay(1.0).build()).layer(1, new DenseLayer.Builder().nIn(2).nOut(2).updater(Updater.ADADELTA).rho(0.5).build()).build();
    net = new MultiLayerNetwork(conf);
    net.init();
    assertEquals("RMSPROP", conf.getConf(0).getLayer().getUpdater().toString());
    assertEquals("ADADELTA", conf.getConf(1).getLayer().getUpdater().toString());
    assertEquals(0.5, conf.getConf(1).getLayer().getRho(), 0.0);
    assertEquals(1.0, conf.getConf(0).getLayer().getRmsDecay(), 0.0);
}
Also used : MultiLayerNetwork(org.deeplearning4j.nn.multilayer.MultiLayerNetwork) Test(org.junit.Test)

Example 85 with MultiLayerNetwork

use of org.deeplearning4j.nn.multilayer.MultiLayerNetwork in project deeplearning4j by deeplearning4j.

the class LayerConfigTest method testLearningRatePolicyPoly.

@Test
public void testLearningRatePolicyPoly() {
    double lr = 2;
    double lrDecayRate = 5;
    double power = 3;
    int iterations = 1;
    MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().iterations(iterations).learningRate(lr).learningRateDecayPolicy(LearningRatePolicy.Poly).lrPolicyDecayRate(lrDecayRate).lrPolicyPower(power).list().layer(0, new DenseLayer.Builder().nIn(2).nOut(2).build()).layer(1, new DenseLayer.Builder().nIn(2).nOut(2).build()).build();
    MultiLayerNetwork net = new MultiLayerNetwork(conf);
    net.init();
    assertEquals(LearningRatePolicy.Poly, conf.getConf(0).getLearningRatePolicy());
    assertEquals(LearningRatePolicy.Poly, conf.getConf(1).getLearningRatePolicy());
    assertEquals(lrDecayRate, conf.getConf(0).getLrPolicyDecayRate(), 0.0);
    assertEquals(lrDecayRate, conf.getConf(1).getLrPolicyDecayRate(), 0.0);
    assertEquals(power, conf.getConf(0).getLrPolicyPower(), 0.0);
    assertEquals(power, conf.getConf(1).getLrPolicyPower(), 0.0);
}
Also used : MultiLayerNetwork(org.deeplearning4j.nn.multilayer.MultiLayerNetwork) Test(org.junit.Test)

Aggregations

MultiLayerNetwork (org.deeplearning4j.nn.multilayer.MultiLayerNetwork)326 Test (org.junit.Test)277 MultiLayerConfiguration (org.deeplearning4j.nn.conf.MultiLayerConfiguration)206 INDArray (org.nd4j.linalg.api.ndarray.INDArray)166 NeuralNetConfiguration (org.deeplearning4j.nn.conf.NeuralNetConfiguration)111 DataSet (org.nd4j.linalg.dataset.DataSet)91 DataSetIterator (org.nd4j.linalg.dataset.api.iterator.DataSetIterator)70 IrisDataSetIterator (org.deeplearning4j.datasets.iterator.impl.IrisDataSetIterator)49 NormalDistribution (org.deeplearning4j.nn.conf.distribution.NormalDistribution)43 ScoreIterationListener (org.deeplearning4j.optimize.listeners.ScoreIterationListener)41 OutputLayer (org.deeplearning4j.nn.conf.layers.OutputLayer)40 DenseLayer (org.deeplearning4j.nn.conf.layers.DenseLayer)38 Random (java.util.Random)34 MnistDataSetIterator (org.deeplearning4j.datasets.iterator.impl.MnistDataSetIterator)30 ConvolutionLayer (org.deeplearning4j.nn.conf.layers.ConvolutionLayer)28 DL4JException (org.deeplearning4j.exception.DL4JException)20 Layer (org.deeplearning4j.nn.api.Layer)20 ClassPathResource (org.nd4j.linalg.io.ClassPathResource)20 File (java.io.File)19 ComputationGraph (org.deeplearning4j.nn.graph.ComputationGraph)19