parent
9af4f9f23a
commit
3edb90dbd1
|
@ -205,7 +205,7 @@ public class TupleStreamDataSetIteratorTest extends SolrCloudTestCase {
|
||||||
public void modelFitTest() throws Exception {
|
public void modelFitTest() throws Exception {
|
||||||
|
|
||||||
final MultiLayerNetwork model = new MultiLayerNetwork(
|
final MultiLayerNetwork model = new MultiLayerNetwork(
|
||||||
new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration.builder()
|
||||||
.list(
|
.list(
|
||||||
new OutputLayer.Builder(LossFunction.MSE)
|
new OutputLayer.Builder(LossFunction.MSE)
|
||||||
.nIn(3)
|
.nIn(3)
|
||||||
|
|
|
@ -35,7 +35,7 @@ import org.apache.solr.client.solrj.request.UpdateRequest;
|
||||||
import org.apache.solr.cloud.SolrCloudTestCase;
|
import org.apache.solr.cloud.SolrCloudTestCase;
|
||||||
import org.apache.solr.common.params.ModifiableSolrParams;
|
import org.apache.solr.common.params.ModifiableSolrParams;
|
||||||
import org.deeplearning4j.nn.api.Model;
|
import org.deeplearning4j.nn.api.Model;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.layers.OutputLayer;
|
import org.deeplearning4j.nn.conf.layers.OutputLayer;
|
||||||
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
||||||
|
@ -153,7 +153,7 @@ public class ModelTupleStreamIntegrationTest extends SolrCloudTestCase {
|
||||||
final int numInputs = 3;
|
final int numInputs = 3;
|
||||||
final int numOutputs = 2;
|
final int numOutputs = 2;
|
||||||
|
|
||||||
final MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
final NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.list(
|
.list(
|
||||||
new OutputLayer.Builder()
|
new OutputLayer.Builder()
|
||||||
.nIn(numInputs)
|
.nIn(numInputs)
|
||||||
|
|
|
@ -43,7 +43,7 @@ import org.apache.solr.core.SolrResourceLoader;
|
||||||
import org.apache.solr.handler.SolrDefaultStreamFactory;
|
import org.apache.solr.handler.SolrDefaultStreamFactory;
|
||||||
import org.deeplearning4j.nn.api.Model;
|
import org.deeplearning4j.nn.api.Model;
|
||||||
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.layers.OutputLayer;
|
import org.deeplearning4j.nn.conf.layers.OutputLayer;
|
||||||
import org.deeplearning4j.nn.graph.ComputationGraph;
|
import org.deeplearning4j.nn.graph.ComputationGraph;
|
||||||
|
@ -242,7 +242,7 @@ public class ModelTupleStreamTest {
|
||||||
|
|
||||||
protected Model buildMultiLayerNetworkModel(int numInputs, int numOutputs) throws Exception {
|
protected Model buildMultiLayerNetworkModel(int numInputs, int numOutputs) throws Exception {
|
||||||
|
|
||||||
final MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
final NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.list(
|
.list(
|
||||||
new OutputLayer.Builder()
|
new OutputLayer.Builder()
|
||||||
.nIn(numInputs)
|
.nIn(numInputs)
|
||||||
|
@ -274,7 +274,7 @@ public class ModelTupleStreamTest {
|
||||||
|
|
||||||
protected Model buildComputationGraphModel(int numInputs, int numOutputs) throws Exception {
|
protected Model buildComputationGraphModel(int numInputs, int numOutputs) throws Exception {
|
||||||
|
|
||||||
final ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder()
|
final ComputationGraphConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.graphBuilder()
|
.graphBuilder()
|
||||||
.addInputs("inputLayer")
|
.addInputs("inputLayer")
|
||||||
.addLayer("outputLayer",
|
.addLayer("outputLayer",
|
||||||
|
|
|
@ -42,7 +42,7 @@ import org.apache.solr.ltr.norm.Normalizer;
|
||||||
import org.apache.solr.request.SolrQueryRequest;
|
import org.apache.solr.request.SolrQueryRequest;
|
||||||
import org.deeplearning4j.nn.api.Model;
|
import org.deeplearning4j.nn.api.Model;
|
||||||
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.layers.OutputLayer;
|
import org.deeplearning4j.nn.conf.layers.OutputLayer;
|
||||||
import org.deeplearning4j.nn.graph.ComputationGraph;
|
import org.deeplearning4j.nn.graph.ComputationGraph;
|
||||||
|
@ -192,7 +192,7 @@ public class ScoringModelTest {
|
||||||
|
|
||||||
protected Model buildMultiLayerNetworkModel(int numFeatures) throws Exception {
|
protected Model buildMultiLayerNetworkModel(int numFeatures) throws Exception {
|
||||||
|
|
||||||
final MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
final NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.list(
|
.list(
|
||||||
new OutputLayer.Builder().nIn(numFeatures).nOut(1).lossFunction(LossFunctions.LossFunction.MSE).activation(Activation.IDENTITY).build()
|
new OutputLayer.Builder().nIn(numFeatures).nOut(1).lossFunction(LossFunctions.LossFunction.MSE).activation(Activation.IDENTITY).build()
|
||||||
)
|
)
|
||||||
|
@ -217,7 +217,7 @@ public class ScoringModelTest {
|
||||||
|
|
||||||
protected Model buildComputationGraphModel(int numFeatures) throws Exception {
|
protected Model buildComputationGraphModel(int numFeatures) throws Exception {
|
||||||
|
|
||||||
final ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder()
|
final ComputationGraphConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.graphBuilder()
|
.graphBuilder()
|
||||||
.addInputs("inputLayer")
|
.addInputs("inputLayer")
|
||||||
.addLayer("outputLayer",
|
.addLayer("outputLayer",
|
||||||
|
|
|
@ -23,7 +23,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import lombok.val;
|
import lombok.val;
|
||||||
import org.deeplearning4j.BaseDL4JTest;
|
import org.deeplearning4j.BaseDL4JTest;
|
||||||
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.graph.MergeVertex;
|
import org.deeplearning4j.nn.conf.graph.MergeVertex;
|
||||||
import org.deeplearning4j.nn.conf.layers.*;
|
import org.deeplearning4j.nn.conf.layers.*;
|
||||||
|
@ -70,7 +70,7 @@ public class JsonModelServerTest extends BaseDL4JTest {
|
||||||
private static final MultiLayerNetwork model;
|
private static final MultiLayerNetwork model;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
val conf = new NeuralNetConfiguration.Builder()
|
val conf = NeuralNetConfiguration.builder()
|
||||||
.seed(119)
|
.seed(119)
|
||||||
.updater(new Adam(0.119f))
|
.updater(new Adam(0.119f))
|
||||||
.weightInit(WeightInit.XAVIER)
|
.weightInit(WeightInit.XAVIER)
|
||||||
|
@ -541,7 +541,7 @@ public class JsonModelServerTest extends BaseDL4JTest {
|
||||||
@Test
|
@Test
|
||||||
public void testMlnMnist() throws Exception {
|
public void testMlnMnist() throws Exception {
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.list()
|
.list()
|
||||||
.layer(new DenseLayer.Builder().nIn(784).nOut(10).build())
|
.layer(new DenseLayer.Builder().nIn(784).nOut(10).build())
|
||||||
.layer(new LossLayer.Builder().activation(Activation.SOFTMAX).build())
|
.layer(new LossLayer.Builder().activation(Activation.SOFTMAX).build())
|
||||||
|
@ -597,7 +597,7 @@ public class JsonModelServerTest extends BaseDL4JTest {
|
||||||
@Test
|
@Test
|
||||||
public void testCompGraph() throws Exception {
|
public void testCompGraph() throws Exception {
|
||||||
|
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder()
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.graphBuilder()
|
.graphBuilder()
|
||||||
.addInputs("input1", "input2")
|
.addInputs("input1", "input2")
|
||||||
.addLayer("L1", new DenseLayer.Builder().nIn(3).nOut(4).build(), "input1")
|
.addLayer("L1", new DenseLayer.Builder().nIn(3).nOut(4).build(), "input1")
|
||||||
|
@ -652,7 +652,7 @@ public class JsonModelServerTest extends BaseDL4JTest {
|
||||||
@Test
|
@Test
|
||||||
public void testCompGraph_1() throws Exception {
|
public void testCompGraph_1() throws Exception {
|
||||||
|
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder()
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.updater(new Sgd(0.01))
|
.updater(new Sgd(0.01))
|
||||||
.graphBuilder()
|
.graphBuilder()
|
||||||
.addInputs("input")
|
.addInputs("input")
|
||||||
|
|
|
@ -425,7 +425,7 @@ public class SharedTrainingWrapper {
|
||||||
.setTrainingWorkspaceMode(trainingConfiguration.getWorkspaceMode());
|
.setTrainingWorkspaceMode(trainingConfiguration.getWorkspaceMode());
|
||||||
((ComputationGraph) originalModel).setGradientsAccumulator(accumulator);
|
((ComputationGraph) originalModel).setGradientsAccumulator(accumulator);
|
||||||
} else if (model instanceof MultiLayerNetwork) {
|
} else if (model instanceof MultiLayerNetwork) {
|
||||||
((MultiLayerNetwork) originalModel).getLayerWiseConfigurations()
|
((MultiLayerNetwork) originalModel).getConfiguration()
|
||||||
.setTrainingWorkspaceMode(trainingConfiguration.getWorkspaceMode());
|
.setTrainingWorkspaceMode(trainingConfiguration.getWorkspaceMode());
|
||||||
((MultiLayerNetwork) originalModel).setGradientsAccumulator(accumulator);
|
((MultiLayerNetwork) originalModel).setGradientsAccumulator(accumulator);
|
||||||
}
|
}
|
||||||
|
|
|
@ -261,7 +261,7 @@ public class SharedTrainingMaster extends BaseTrainingMaster<SharedTrainingResul
|
||||||
/*
|
/*
|
||||||
Here we're going create our worker, which will be passed into corresponding FlatMapFunction
|
Here we're going create our worker, which will be passed into corresponding FlatMapFunction
|
||||||
*/
|
*/
|
||||||
NetBroadcastTuple tuple = new NetBroadcastTuple(network.getNetwork().getLayerWiseConfigurations(),
|
NetBroadcastTuple tuple = new NetBroadcastTuple(network.getNetwork().getConfiguration(),
|
||||||
network.getNetwork().params(), network.getNetwork().getUpdater().getStateViewArray());
|
network.getNetwork().params(), network.getNetwork().getUpdater().getStateViewArray());
|
||||||
|
|
||||||
voidConfiguration.setUnicastControllerPort(voidConfiguration.getPortSupplier().getPort());
|
voidConfiguration.setUnicastControllerPort(voidConfiguration.getPortSupplier().getPort());
|
||||||
|
|
|
@ -24,7 +24,7 @@ import lombok.Getter;
|
||||||
import org.apache.spark.broadcast.Broadcast;
|
import org.apache.spark.broadcast.Broadcast;
|
||||||
import org.deeplearning4j.core.storage.StatsStorageRouter;
|
import org.deeplearning4j.core.storage.StatsStorageRouter;
|
||||||
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.graph.ComputationGraph;
|
import org.deeplearning4j.nn.graph.ComputationGraph;
|
||||||
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
||||||
import org.deeplearning4j.optimize.api.TrainingListener;
|
import org.deeplearning4j.optimize.api.TrainingListener;
|
||||||
|
@ -91,7 +91,7 @@ public class SharedTrainingWorker extends BaseTrainingWorker<SharedTrainingResul
|
||||||
|
|
||||||
NetBroadcastTuple tuple = broadcastModel.getValue();
|
NetBroadcastTuple tuple = broadcastModel.getValue();
|
||||||
if (tuple.getConfiguration() != null) {
|
if (tuple.getConfiguration() != null) {
|
||||||
MultiLayerConfiguration conf = tuple.getConfiguration();
|
NeuralNetConfiguration conf = tuple.getConfiguration();
|
||||||
MultiLayerNetwork network = new MultiLayerNetwork(conf);
|
MultiLayerNetwork network = new MultiLayerNetwork(conf);
|
||||||
network.init();
|
network.init();
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ import org.apache.spark.SparkConf;
|
||||||
import org.apache.spark.api.java.JavaRDD;
|
import org.apache.spark.api.java.JavaRDD;
|
||||||
import org.apache.spark.api.java.JavaSparkContext;
|
import org.apache.spark.api.java.JavaSparkContext;
|
||||||
import org.deeplearning4j.BaseDL4JTest;
|
import org.deeplearning4j.BaseDL4JTest;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.spark.impl.multilayer.SparkDl4jMultiLayer;
|
import org.deeplearning4j.spark.impl.multilayer.SparkDl4jMultiLayer;
|
||||||
import org.deeplearning4j.spark.impl.paramavg.ParameterAveragingTrainingMaster;
|
import org.deeplearning4j.spark.impl.paramavg.ParameterAveragingTrainingMaster;
|
||||||
|
@ -126,8 +126,8 @@ public abstract class BaseSparkTest extends BaseDL4JTest implements Serializable
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected MultiLayerConfiguration getBasicConf() {
|
protected NeuralNetConfiguration getBasicConf() {
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().seed(123)
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().seed(123)
|
||||||
.updater(new Nesterovs(0.1, 0.9)).list()
|
.updater(new Nesterovs(0.1, 0.9)).list()
|
||||||
.layer(0, new org.deeplearning4j.nn.conf.layers.DenseLayer.Builder().nIn(nIn).nOut(3)
|
.layer(0, new org.deeplearning4j.nn.conf.layers.DenseLayer.Builder().nIn(nIn).nOut(3)
|
||||||
.activation(Activation.TANH).build())
|
.activation(Activation.TANH).build())
|
||||||
|
|
|
@ -28,7 +28,7 @@ import org.deeplearning4j.datasets.iterator.impl.MnistDataSetIterator;
|
||||||
import org.deeplearning4j.eval.Evaluation;
|
import org.deeplearning4j.eval.Evaluation;
|
||||||
import org.deeplearning4j.nn.api.Model;
|
import org.deeplearning4j.nn.api.Model;
|
||||||
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.layers.DenseLayer;
|
import org.deeplearning4j.nn.conf.layers.DenseLayer;
|
||||||
import org.deeplearning4j.nn.conf.layers.OutputLayer;
|
import org.deeplearning4j.nn.conf.layers.OutputLayer;
|
||||||
|
@ -132,7 +132,7 @@ public class GradientSharingTrainingTest extends BaseSparkTest {
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder()
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.seed(12345)
|
.seed(12345)
|
||||||
.updater(new AMSGrad(0.1))
|
.updater(new AMSGrad(0.1))
|
||||||
.graphBuilder()
|
.graphBuilder()
|
||||||
|
@ -266,16 +266,16 @@ public class GradientSharingTrainingTest extends BaseSparkTest {
|
||||||
System.out.println("||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||");
|
System.out.println("||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||");
|
||||||
log.info("Starting: {}", i);
|
log.info("Starting: {}", i);
|
||||||
|
|
||||||
MultiLayerConfiguration conf;
|
NeuralNetConfiguration conf;
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
conf = new NeuralNetConfiguration.Builder()
|
conf = NeuralNetConfiguration.builder()
|
||||||
.weightInit(WeightInit.XAVIER)
|
.weightInit(WeightInit.XAVIER)
|
||||||
.seed(12345)
|
.seed(12345)
|
||||||
.list()
|
.list()
|
||||||
.layer(new OutputLayer.Builder().nIn(4).nOut(3).activation(Activation.SOFTMAX).lossFunction(LossFunctions.LossFunction.MCXENT).build())
|
.layer(new OutputLayer.Builder().nIn(4).nOut(3).activation(Activation.SOFTMAX).lossFunction(LossFunctions.LossFunction.MCXENT).build())
|
||||||
.build();
|
.build();
|
||||||
} else {
|
} else {
|
||||||
conf = new NeuralNetConfiguration.Builder()
|
conf = NeuralNetConfiguration.builder()
|
||||||
.weightInit(WeightInit.XAVIER)
|
.weightInit(WeightInit.XAVIER)
|
||||||
.seed(12345)
|
.seed(12345)
|
||||||
.list()
|
.list()
|
||||||
|
@ -353,7 +353,7 @@ public class GradientSharingTrainingTest extends BaseSparkTest {
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder()
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.seed(12345)
|
.seed(12345)
|
||||||
.updater(new AMSGrad(0.001))
|
.updater(new AMSGrad(0.001))
|
||||||
.graphBuilder()
|
.graphBuilder()
|
||||||
|
|
|
@ -22,7 +22,7 @@ package org.deeplearning4j.spark.api.worker;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.nd4j.linalg.api.ndarray.INDArray;
|
import org.nd4j.linalg.api.ndarray.INDArray;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
@ -31,13 +31,13 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||||
@Data
|
@Data
|
||||||
public class NetBroadcastTuple implements Serializable {
|
public class NetBroadcastTuple implements Serializable {
|
||||||
|
|
||||||
private final MultiLayerConfiguration configuration;
|
private final NeuralNetConfiguration configuration;
|
||||||
private final ComputationGraphConfiguration graphConfiguration;
|
private final ComputationGraphConfiguration graphConfiguration;
|
||||||
private final INDArray parameters;
|
private final INDArray parameters;
|
||||||
private final INDArray updaterState;
|
private final INDArray updaterState;
|
||||||
private final AtomicInteger counter;
|
private final AtomicInteger counter;
|
||||||
|
|
||||||
public NetBroadcastTuple(MultiLayerConfiguration configuration, INDArray parameters, INDArray updaterState) {
|
public NetBroadcastTuple(NeuralNetConfiguration configuration, INDArray parameters, INDArray updaterState) {
|
||||||
this(configuration, null, parameters, updaterState);
|
this(configuration, null, parameters, updaterState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,12 +47,12 @@ public class NetBroadcastTuple implements Serializable {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public NetBroadcastTuple(MultiLayerConfiguration configuration, ComputationGraphConfiguration graphConfiguration,
|
public NetBroadcastTuple(NeuralNetConfiguration configuration, ComputationGraphConfiguration graphConfiguration,
|
||||||
INDArray parameters, INDArray updaterState) {
|
INDArray parameters, INDArray updaterState) {
|
||||||
this(configuration, graphConfiguration, parameters, updaterState, new AtomicInteger(0));
|
this(configuration, graphConfiguration, parameters, updaterState, new AtomicInteger(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public NetBroadcastTuple(MultiLayerConfiguration configuration, ComputationGraphConfiguration graphConfiguration,
|
public NetBroadcastTuple(NeuralNetConfiguration configuration, ComputationGraphConfiguration graphConfiguration,
|
||||||
INDArray parameters, INDArray updaterState, AtomicInteger counter) {
|
INDArray parameters, INDArray updaterState, AtomicInteger counter) {
|
||||||
this.configuration = configuration;
|
this.configuration = configuration;
|
||||||
this.graphConfiguration = graphConfiguration;
|
this.graphConfiguration = graphConfiguration;
|
||||||
|
|
|
@ -31,7 +31,7 @@ public abstract class BaseVaeReconstructionProbWithKeyFunction<K> extends BaseVa
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param params MultiLayerNetwork parameters
|
* @param params MultiLayerNetwork parameters
|
||||||
* @param jsonConfig MultiLayerConfiguration, as json
|
* @param jsonConfig NeuralNetConfiguration, as json
|
||||||
* @param useLogProbability If true: use log probability. False: use raw probability.
|
* @param useLogProbability If true: use log probability. False: use raw probability.
|
||||||
* @param batchSize Batch size to use when scoring
|
* @param batchSize Batch size to use when scoring
|
||||||
* @param numSamples Number of samples to use when calling {@link VariationalAutoencoder#reconstructionLogProbability(INDArray, int)}
|
* @param numSamples Number of samples to use when calling {@link VariationalAutoencoder#reconstructionLogProbability(INDArray, int)}
|
||||||
|
|
|
@ -45,7 +45,7 @@ public abstract class BaseVaeScoreWithKeyFunction<K> implements PairFlatMapFunct
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param params MultiLayerNetwork parameters
|
* @param params MultiLayerNetwork parameters
|
||||||
* @param jsonConfig MultiLayerConfiguration, as json
|
* @param jsonConfig NeuralNetConfiguration, as json
|
||||||
* @param batchSize Batch size to use when scoring
|
* @param batchSize Batch size to use when scoring
|
||||||
*/
|
*/
|
||||||
public BaseVaeScoreWithKeyFunction(Broadcast<INDArray> params, Broadcast<String> jsonConfig, int batchSize) {
|
public BaseVaeScoreWithKeyFunction(Broadcast<INDArray> params, Broadcast<String> jsonConfig, int batchSize) {
|
||||||
|
|
|
@ -27,7 +27,7 @@ import org.deeplearning4j.datasets.iterator.IteratorDataSetIterator;
|
||||||
import org.deeplearning4j.datasets.iterator.IteratorMultiDataSetIterator;
|
import org.deeplearning4j.datasets.iterator.IteratorMultiDataSetIterator;
|
||||||
import org.deeplearning4j.nn.api.Model;
|
import org.deeplearning4j.nn.api.Model;
|
||||||
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.graph.ComputationGraph;
|
import org.deeplearning4j.nn.graph.ComputationGraph;
|
||||||
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
||||||
import org.nd4j.common.base.Preconditions;
|
import org.nd4j.common.base.Preconditions;
|
||||||
|
@ -131,7 +131,7 @@ public class EvaluationRunner {
|
||||||
cg.init(deviceLocalParams.get(), false);
|
cg.init(deviceLocalParams.get(), false);
|
||||||
m = cg;
|
m = cg;
|
||||||
} else {
|
} else {
|
||||||
MultiLayerConfiguration conf = MultiLayerConfiguration.fromJson(json.getValue());
|
NeuralNetConfiguration conf = NeuralNetConfiguration.fromJson(json.getValue());
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
net.init(deviceLocalParams.get(), false);
|
net.init(deviceLocalParams.get(), false);
|
||||||
m = net;
|
m = net;
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class CGVaeReconstructionErrorWithKeyFunction<K> extends BaseVaeScoreWith
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param params MultiLayerNetwork parameters
|
* @param params MultiLayerNetwork parameters
|
||||||
* @param jsonConfig MultiLayerConfiguration, as json
|
* @param jsonConfig NeuralNetConfiguration, as json
|
||||||
* @param batchSize Batch size to use when scoring
|
* @param batchSize Batch size to use when scoring
|
||||||
*/
|
*/
|
||||||
public CGVaeReconstructionErrorWithKeyFunction(Broadcast<INDArray> params, Broadcast<String> jsonConfig,
|
public CGVaeReconstructionErrorWithKeyFunction(Broadcast<INDArray> params, Broadcast<String> jsonConfig,
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class CGVaeReconstructionProbWithKeyFunction<K> extends BaseVaeReconstruc
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param params MultiLayerNetwork parameters
|
* @param params MultiLayerNetwork parameters
|
||||||
* @param jsonConfig MultiLayerConfiguration, as json
|
* @param jsonConfig NeuralNetConfiguration, as json
|
||||||
* @param useLogProbability If true: use log probability. False: use raw probability.
|
* @param useLogProbability If true: use log probability. False: use raw probability.
|
||||||
* @param batchSize Batch size to use when scoring
|
* @param batchSize Batch size to use when scoring
|
||||||
* @param numSamples Number of samples to use when calling {@link VariationalAutoencoder#reconstructionLogProbability(INDArray, int)}
|
* @param numSamples Number of samples to use when calling {@link VariationalAutoencoder#reconstructionLogProbability(INDArray, int)}
|
||||||
|
|
|
@ -35,7 +35,7 @@ import org.datavec.spark.util.BroadcastHadoopConfigHolder;
|
||||||
import org.deeplearning4j.core.loader.DataSetLoader;
|
import org.deeplearning4j.core.loader.DataSetLoader;
|
||||||
import org.deeplearning4j.core.loader.MultiDataSetLoader;
|
import org.deeplearning4j.core.loader.MultiDataSetLoader;
|
||||||
import org.deeplearning4j.core.loader.impl.SerializedDataSetLoader;
|
import org.deeplearning4j.core.loader.impl.SerializedDataSetLoader;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.layers.FeedForwardLayer;
|
import org.deeplearning4j.nn.conf.layers.FeedForwardLayer;
|
||||||
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
||||||
import org.deeplearning4j.spark.api.TrainingMaster;
|
import org.deeplearning4j.spark.api.TrainingMaster;
|
||||||
|
@ -80,7 +80,7 @@ public class SparkDl4jMultiLayer extends SparkListenable {
|
||||||
public static final int DEFAULT_ROC_THRESHOLD_STEPS = 32;
|
public static final int DEFAULT_ROC_THRESHOLD_STEPS = 32;
|
||||||
public static final int DEFAULT_EVAL_WORKERS = 4;
|
public static final int DEFAULT_EVAL_WORKERS = 4;
|
||||||
private transient JavaSparkContext sc;
|
private transient JavaSparkContext sc;
|
||||||
private MultiLayerConfiguration conf;
|
private NeuralNetConfiguration conf;
|
||||||
private MultiLayerNetwork network;
|
private MultiLayerNetwork network;
|
||||||
private double lastScore;
|
private double lastScore;
|
||||||
private int defaultEvaluationWorkers = DEFAULT_EVAL_WORKERS;
|
private int defaultEvaluationWorkers = DEFAULT_EVAL_WORKERS;
|
||||||
|
@ -104,7 +104,7 @@ public class SparkDl4jMultiLayer extends SparkListenable {
|
||||||
* @param sparkContext the spark context to use
|
* @param sparkContext the spark context to use
|
||||||
* @param conf the configuration of the network
|
* @param conf the configuration of the network
|
||||||
*/
|
*/
|
||||||
public SparkDl4jMultiLayer(SparkContext sparkContext, MultiLayerConfiguration conf,
|
public SparkDl4jMultiLayer(SparkContext sparkContext, NeuralNetConfiguration conf,
|
||||||
TrainingMaster<?, ?> trainingMaster) {
|
TrainingMaster<?, ?> trainingMaster) {
|
||||||
this(new JavaSparkContext(sparkContext), initNetwork(conf), trainingMaster);
|
this(new JavaSparkContext(sparkContext), initNetwork(conf), trainingMaster);
|
||||||
}
|
}
|
||||||
|
@ -115,14 +115,14 @@ public class SparkDl4jMultiLayer extends SparkListenable {
|
||||||
* @param sc the spark context to use
|
* @param sc the spark context to use
|
||||||
* @param conf the configuration of the network
|
* @param conf the configuration of the network
|
||||||
*/
|
*/
|
||||||
public SparkDl4jMultiLayer(JavaSparkContext sc, MultiLayerConfiguration conf, TrainingMaster<?, ?> trainingMaster) {
|
public SparkDl4jMultiLayer(JavaSparkContext sc, NeuralNetConfiguration conf, TrainingMaster<?, ?> trainingMaster) {
|
||||||
this(sc.sc(), conf, trainingMaster);
|
this(sc.sc(), conf, trainingMaster);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SparkDl4jMultiLayer(JavaSparkContext javaSparkContext, MultiLayerNetwork network,
|
public SparkDl4jMultiLayer(JavaSparkContext javaSparkContext, MultiLayerNetwork network,
|
||||||
TrainingMaster<?, ?> trainingMaster) {
|
TrainingMaster<?, ?> trainingMaster) {
|
||||||
sc = javaSparkContext;
|
sc = javaSparkContext;
|
||||||
this.conf = network.getLayerWiseConfigurations().clone();
|
this.conf = network.getConfiguration().clone();
|
||||||
this.network = network;
|
this.network = network;
|
||||||
if (!network.isInitCalled())
|
if (!network.isInitCalled())
|
||||||
network.init();
|
network.init();
|
||||||
|
@ -132,7 +132,7 @@ public class SparkDl4jMultiLayer extends SparkListenable {
|
||||||
SparkUtils.checkKryoConfiguration(javaSparkContext, log);
|
SparkUtils.checkKryoConfiguration(javaSparkContext, log);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static MultiLayerNetwork initNetwork(MultiLayerConfiguration conf) {
|
private static MultiLayerNetwork initNetwork(NeuralNetConfiguration conf) {
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
net.init();
|
net.init();
|
||||||
return net;
|
return net;
|
||||||
|
@ -315,8 +315,8 @@ public class SparkDl4jMultiLayer extends SparkListenable {
|
||||||
* @return the multi layer network that was fitDataSet
|
* @return the multi layer network that was fitDataSet
|
||||||
*/
|
*/
|
||||||
public MultiLayerNetwork fitLabeledPoint(JavaRDD<LabeledPoint> rdd) {
|
public MultiLayerNetwork fitLabeledPoint(JavaRDD<LabeledPoint> rdd) {
|
||||||
int nLayers = network.getLayerWiseConfigurations().getConfs().size();
|
int nLayers = network.getConfiguration().getConfs().size();
|
||||||
FeedForwardLayer ffl = (FeedForwardLayer) network.getLayerWiseConfigurations().getConf(nLayers - 1).getLayer();
|
FeedForwardLayer ffl = (FeedForwardLayer) network.getConfiguration().getConf(nLayers - 1).getLayer();
|
||||||
JavaRDD<DataSet> ds = MLLibUtil.fromLabeledPoint(sc, rdd, ffl.getNOut());
|
JavaRDD<DataSet> ds = MLLibUtil.fromLabeledPoint(sc, rdd, ffl.getNOut());
|
||||||
return fit(ds);
|
return fit(ds);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ package org.deeplearning4j.spark.impl.multilayer.scoring;
|
||||||
|
|
||||||
import org.apache.spark.api.java.function.PairFlatMapFunction;
|
import org.apache.spark.api.java.function.PairFlatMapFunction;
|
||||||
import org.apache.spark.broadcast.Broadcast;
|
import org.apache.spark.broadcast.Broadcast;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
||||||
import org.nd4j.linalg.api.ndarray.INDArray;
|
import org.nd4j.linalg.api.ndarray.INDArray;
|
||||||
import org.nd4j.linalg.dataset.api.DataSetUtil;
|
import org.nd4j.linalg.dataset.api.DataSetUtil;
|
||||||
|
@ -49,7 +49,7 @@ public class FeedForwardWithKeyFunction<K>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param params MultiLayerNetwork parameters
|
* @param params MultiLayerNetwork parameters
|
||||||
* @param jsonConfig MultiLayerConfiguration, as json
|
* @param jsonConfig NeuralNetConfiguration, as json
|
||||||
* @param batchSize Batch size to use for forward pass (use > 1 for efficiency)
|
* @param batchSize Batch size to use for forward pass (use > 1 for efficiency)
|
||||||
*/
|
*/
|
||||||
public FeedForwardWithKeyFunction(Broadcast<INDArray> params, Broadcast<String> jsonConfig, int batchSize) {
|
public FeedForwardWithKeyFunction(Broadcast<INDArray> params, Broadcast<String> jsonConfig, int batchSize) {
|
||||||
|
@ -65,7 +65,7 @@ public class FeedForwardWithKeyFunction<K>
|
||||||
return Collections.emptyIterator();
|
return Collections.emptyIterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiLayerNetwork network = new MultiLayerNetwork(MultiLayerConfiguration.fromJson(jsonConfig.getValue()));
|
MultiLayerNetwork network = new MultiLayerNetwork(NeuralNetConfiguration.fromJson(jsonConfig.getValue()));
|
||||||
network.init();
|
network.init();
|
||||||
INDArray val = params.value().unsafeDuplication();
|
INDArray val = params.value().unsafeDuplication();
|
||||||
if (val.length() != network.numParams(false))
|
if (val.length() != network.numParams(false))
|
||||||
|
|
|
@ -23,7 +23,7 @@ package org.deeplearning4j.spark.impl.multilayer.scoring;
|
||||||
import org.apache.spark.api.java.function.DoubleFlatMapFunction;
|
import org.apache.spark.api.java.function.DoubleFlatMapFunction;
|
||||||
import org.apache.spark.api.java.function.FlatMapFunction;
|
import org.apache.spark.api.java.function.FlatMapFunction;
|
||||||
import org.apache.spark.broadcast.Broadcast;
|
import org.apache.spark.broadcast.Broadcast;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
||||||
import org.nd4j.linalg.api.ndarray.INDArray;
|
import org.nd4j.linalg.api.ndarray.INDArray;
|
||||||
import org.nd4j.linalg.dataset.DataSet;
|
import org.nd4j.linalg.dataset.DataSet;
|
||||||
|
@ -60,7 +60,7 @@ public class ScoreExamplesFunction implements DoubleFlatMapFunction<Iterator<Dat
|
||||||
return Collections.emptyIterator();
|
return Collections.emptyIterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiLayerNetwork network = new MultiLayerNetwork(MultiLayerConfiguration.fromJson(jsonConfig.getValue()));
|
MultiLayerNetwork network = new MultiLayerNetwork(NeuralNetConfiguration.fromJson(jsonConfig.getValue()));
|
||||||
network.init();
|
network.init();
|
||||||
INDArray val = params.value().unsafeDuplication();
|
INDArray val = params.value().unsafeDuplication();
|
||||||
if (val.length() != network.numParams(false))
|
if (val.length() != network.numParams(false))
|
||||||
|
|
|
@ -23,7 +23,7 @@ package org.deeplearning4j.spark.impl.multilayer.scoring;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.spark.api.java.function.PairFlatMapFunction;
|
import org.apache.spark.api.java.function.PairFlatMapFunction;
|
||||||
import org.apache.spark.broadcast.Broadcast;
|
import org.apache.spark.broadcast.Broadcast;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
||||||
import org.nd4j.linalg.api.ndarray.INDArray;
|
import org.nd4j.linalg.api.ndarray.INDArray;
|
||||||
import org.nd4j.linalg.dataset.DataSet;
|
import org.nd4j.linalg.dataset.DataSet;
|
||||||
|
@ -45,7 +45,7 @@ public class ScoreExamplesWithKeyFunction<K> implements PairFlatMapFunction<Iter
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param params MultiLayerNetwork parameters
|
* @param params MultiLayerNetwork parameters
|
||||||
* @param jsonConfig MultiLayerConfiguration, as json
|
* @param jsonConfig NeuralNetConfiguration, as json
|
||||||
* @param addRegularizationTerms if true: add regularization terms (L1, L2) to the score
|
* @param addRegularizationTerms if true: add regularization terms (L1, L2) to the score
|
||||||
* @param batchSize Batch size to use when scoring
|
* @param batchSize Batch size to use when scoring
|
||||||
*/
|
*/
|
||||||
|
@ -63,7 +63,7 @@ public class ScoreExamplesWithKeyFunction<K> implements PairFlatMapFunction<Iter
|
||||||
return Collections.emptyIterator();
|
return Collections.emptyIterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiLayerNetwork network = new MultiLayerNetwork(MultiLayerConfiguration.fromJson(jsonConfig.getValue()));
|
MultiLayerNetwork network = new MultiLayerNetwork(NeuralNetConfiguration.fromJson(jsonConfig.getValue()));
|
||||||
network.init();
|
network.init();
|
||||||
INDArray val = params.value().unsafeDuplication();
|
INDArray val = params.value().unsafeDuplication();
|
||||||
if (val.length() != network.numParams(false))
|
if (val.length() != network.numParams(false))
|
||||||
|
|
|
@ -26,7 +26,7 @@ import lombok.val;
|
||||||
import org.apache.spark.api.java.function.FlatMapFunction;
|
import org.apache.spark.api.java.function.FlatMapFunction;
|
||||||
import org.apache.spark.broadcast.Broadcast;
|
import org.apache.spark.broadcast.Broadcast;
|
||||||
import org.deeplearning4j.datasets.iterator.IteratorDataSetIterator;
|
import org.deeplearning4j.datasets.iterator.IteratorDataSetIterator;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
||||||
import org.nd4j.linalg.api.ndarray.INDArray;
|
import org.nd4j.linalg.api.ndarray.INDArray;
|
||||||
import org.nd4j.linalg.dataset.DataSet;
|
import org.nd4j.linalg.dataset.DataSet;
|
||||||
|
@ -55,7 +55,7 @@ public class ScoreFlatMapFunction implements FlatMapFunction<Iterator<DataSet>,
|
||||||
|
|
||||||
DataSetIterator iter = new IteratorDataSetIterator(dataSetIterator, minibatchSize); //Does batching where appropriate
|
DataSetIterator iter = new IteratorDataSetIterator(dataSetIterator, minibatchSize); //Does batching where appropriate
|
||||||
|
|
||||||
MultiLayerNetwork network = new MultiLayerNetwork(MultiLayerConfiguration.fromJson(json));
|
MultiLayerNetwork network = new MultiLayerNetwork(NeuralNetConfiguration.fromJson(json));
|
||||||
network.init();
|
network.init();
|
||||||
INDArray val = params.value().unsafeDuplication(); //.value() object will be shared by all executors on each machine -> OK, as params are not modified by score function
|
INDArray val = params.value().unsafeDuplication(); //.value() object will be shared by all executors on each machine -> OK, as params are not modified by score function
|
||||||
if (val.length() != network.numParams(false))
|
if (val.length() != network.numParams(false))
|
||||||
|
|
|
@ -22,7 +22,7 @@ package org.deeplearning4j.spark.impl.multilayer.scoring;
|
||||||
|
|
||||||
import org.apache.spark.broadcast.Broadcast;
|
import org.apache.spark.broadcast.Broadcast;
|
||||||
import org.deeplearning4j.nn.api.Layer;
|
import org.deeplearning4j.nn.api.Layer;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.layers.variational.VariationalAutoencoder;
|
import org.deeplearning4j.nn.layers.variational.VariationalAutoencoder;
|
||||||
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
||||||
import org.deeplearning4j.spark.impl.common.score.BaseVaeScoreWithKeyFunction;
|
import org.deeplearning4j.spark.impl.common.score.BaseVaeScoreWithKeyFunction;
|
||||||
|
@ -36,7 +36,7 @@ public class VaeReconstructionErrorWithKeyFunction<K> extends BaseVaeScoreWithKe
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param params MultiLayerNetwork parameters
|
* @param params MultiLayerNetwork parameters
|
||||||
* @param jsonConfig MultiLayerConfiguration, as json
|
* @param jsonConfig NeuralNetConfiguration, as json
|
||||||
* @param batchSize Batch size to use when scoring
|
* @param batchSize Batch size to use when scoring
|
||||||
*/
|
*/
|
||||||
public VaeReconstructionErrorWithKeyFunction(Broadcast<INDArray> params, Broadcast<String> jsonConfig,
|
public VaeReconstructionErrorWithKeyFunction(Broadcast<INDArray> params, Broadcast<String> jsonConfig,
|
||||||
|
@ -47,7 +47,7 @@ public class VaeReconstructionErrorWithKeyFunction<K> extends BaseVaeScoreWithKe
|
||||||
@Override
|
@Override
|
||||||
public VariationalAutoencoder getVaeLayer() {
|
public VariationalAutoencoder getVaeLayer() {
|
||||||
MultiLayerNetwork network =
|
MultiLayerNetwork network =
|
||||||
new MultiLayerNetwork(MultiLayerConfiguration.fromJson((String) jsonConfig.getValue()));
|
new MultiLayerNetwork(NeuralNetConfiguration.fromJson((String) jsonConfig.getValue()));
|
||||||
network.init();
|
network.init();
|
||||||
INDArray val = ((INDArray) params.value()).unsafeDuplication();
|
INDArray val = ((INDArray) params.value()).unsafeDuplication();
|
||||||
if (val.length() != network.numParams(false))
|
if (val.length() != network.numParams(false))
|
||||||
|
|
|
@ -22,7 +22,7 @@ package org.deeplearning4j.spark.impl.multilayer.scoring;
|
||||||
|
|
||||||
import org.apache.spark.broadcast.Broadcast;
|
import org.apache.spark.broadcast.Broadcast;
|
||||||
import org.deeplearning4j.nn.api.Layer;
|
import org.deeplearning4j.nn.api.Layer;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.layers.variational.VariationalAutoencoder;
|
import org.deeplearning4j.nn.layers.variational.VariationalAutoencoder;
|
||||||
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
||||||
import org.deeplearning4j.spark.impl.common.score.BaseVaeReconstructionProbWithKeyFunction;
|
import org.deeplearning4j.spark.impl.common.score.BaseVaeReconstructionProbWithKeyFunction;
|
||||||
|
@ -34,7 +34,7 @@ public class VaeReconstructionProbWithKeyFunction<K> extends BaseVaeReconstructi
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param params MultiLayerNetwork parameters
|
* @param params MultiLayerNetwork parameters
|
||||||
* @param jsonConfig MultiLayerConfiguration, as json
|
* @param jsonConfig NeuralNetConfiguration, as json
|
||||||
* @param useLogProbability If true: use log probability. False: use raw probability.
|
* @param useLogProbability If true: use log probability. False: use raw probability.
|
||||||
* @param batchSize Batch size to use when scoring
|
* @param batchSize Batch size to use when scoring
|
||||||
* @param numSamples Number of samples to use when calling {@link VariationalAutoencoder#reconstructionLogProbability(INDArray, int)}
|
* @param numSamples Number of samples to use when calling {@link VariationalAutoencoder#reconstructionLogProbability(INDArray, int)}
|
||||||
|
@ -47,7 +47,7 @@ public class VaeReconstructionProbWithKeyFunction<K> extends BaseVaeReconstructi
|
||||||
@Override
|
@Override
|
||||||
public VariationalAutoencoder getVaeLayer() {
|
public VariationalAutoencoder getVaeLayer() {
|
||||||
MultiLayerNetwork network =
|
MultiLayerNetwork network =
|
||||||
new MultiLayerNetwork(MultiLayerConfiguration.fromJson((String) jsonConfig.getValue()));
|
new MultiLayerNetwork(NeuralNetConfiguration.fromJson((String) jsonConfig.getValue()));
|
||||||
network.init();
|
network.init();
|
||||||
INDArray val = ((INDArray) params.value()).unsafeDuplication();
|
INDArray val = ((INDArray) params.value()).unsafeDuplication();
|
||||||
if (val.length() != network.numParams(false))
|
if (val.length() != network.numParams(false))
|
||||||
|
|
|
@ -41,7 +41,7 @@ import org.deeplearning4j.core.storage.StatsStorageRouter;
|
||||||
import org.deeplearning4j.core.storage.StatsStorageRouterProvider;
|
import org.deeplearning4j.core.storage.StatsStorageRouterProvider;
|
||||||
import org.deeplearning4j.core.storage.StorageMetaData;
|
import org.deeplearning4j.core.storage.StorageMetaData;
|
||||||
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.graph.ComputationGraph;
|
import org.deeplearning4j.nn.graph.ComputationGraph;
|
||||||
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
||||||
import org.deeplearning4j.optimize.api.TrainingListener;
|
import org.deeplearning4j.optimize.api.TrainingListener;
|
||||||
|
@ -274,7 +274,7 @@ public class ParameterAveragingTrainingMaster
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ParameterAveragingTrainingWorker getWorkerInstance(SparkDl4jMultiLayer network) {
|
public ParameterAveragingTrainingWorker getWorkerInstance(SparkDl4jMultiLayer network) {
|
||||||
NetBroadcastTuple tuple = new NetBroadcastTuple(network.getNetwork().getLayerWiseConfigurations(),
|
NetBroadcastTuple tuple = new NetBroadcastTuple(network.getNetwork().getConfiguration(),
|
||||||
network.getNetwork().params(), network.getNetwork().getUpdater().getStateViewArray());
|
network.getNetwork().params(), network.getNetwork().getUpdater().getStateViewArray());
|
||||||
|
|
||||||
if (collectTrainingStats)
|
if (collectTrainingStats)
|
||||||
|
@ -726,7 +726,7 @@ public class ParameterAveragingTrainingMaster
|
||||||
if (params != null) {
|
if (params != null) {
|
||||||
//Params may be null for edge case (empty RDD)
|
//Params may be null for edge case (empty RDD)
|
||||||
if (network != null) {
|
if (network != null) {
|
||||||
MultiLayerConfiguration conf = network.getNetwork().getLayerWiseConfigurations();
|
NeuralNetConfiguration conf = network.getNetwork().getConfiguration();
|
||||||
int numUpdates = averagingFrequency;
|
int numUpdates = averagingFrequency;
|
||||||
conf.setIterationCount(conf.getIterationCount() + numUpdates);
|
conf.setIterationCount(conf.getIterationCount() + numUpdates);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -26,7 +26,7 @@ import org.apache.spark.api.java.JavaRDD;
|
||||||
import org.apache.spark.api.java.JavaSparkContext;
|
import org.apache.spark.api.java.JavaSparkContext;
|
||||||
import org.datavec.spark.util.SerializableHadoopConfig;
|
import org.datavec.spark.util.SerializableHadoopConfig;
|
||||||
import org.deeplearning4j.BaseDL4JTest;
|
import org.deeplearning4j.BaseDL4JTest;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.spark.impl.multilayer.SparkDl4jMultiLayer;
|
import org.deeplearning4j.spark.impl.multilayer.SparkDl4jMultiLayer;
|
||||||
import org.deeplearning4j.spark.impl.paramavg.ParameterAveragingTrainingMaster;
|
import org.deeplearning4j.spark.impl.paramavg.ParameterAveragingTrainingMaster;
|
||||||
|
@ -129,8 +129,8 @@ public abstract class BaseSparkTest extends BaseDL4JTest implements Serializable
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected MultiLayerConfiguration getBasicConf() {
|
protected NeuralNetConfiguration getBasicConf() {
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().seed(123)
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().seed(123)
|
||||||
.updater(new Nesterovs(0.1, 0.9)).list()
|
.updater(new Nesterovs(0.1, 0.9)).list()
|
||||||
.layer(0, new org.deeplearning4j.nn.conf.layers.DenseLayer.Builder().nIn(nIn).nOut(3)
|
.layer(0, new org.deeplearning4j.nn.conf.layers.DenseLayer.Builder().nIn(nIn).nOut(3)
|
||||||
.activation(Activation.TANH).build())
|
.activation(Activation.TANH).build())
|
||||||
|
|
|
@ -35,7 +35,7 @@ import org.deeplearning4j.earlystopping.termination.MaxTimeIterationTerminationC
|
||||||
import org.deeplearning4j.earlystopping.termination.ScoreImprovementEpochTerminationCondition;
|
import org.deeplearning4j.earlystopping.termination.ScoreImprovementEpochTerminationCondition;
|
||||||
import org.deeplearning4j.earlystopping.trainer.IEarlyStoppingTrainer;
|
import org.deeplearning4j.earlystopping.trainer.IEarlyStoppingTrainer;
|
||||||
import org.deeplearning4j.nn.api.OptimizationAlgorithm;
|
import org.deeplearning4j.nn.api.OptimizationAlgorithm;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.layers.OutputLayer;
|
import org.deeplearning4j.nn.conf.layers.OutputLayer;
|
||||||
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
||||||
|
@ -68,7 +68,7 @@ public class TestEarlyStoppingSpark extends BaseSparkTest {
|
||||||
//Spark tests don't run on windows
|
//Spark tests don't run on windows
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.updater(new Sgd()).weightInit(WeightInit.XAVIER).list()
|
.updater(new Sgd()).weightInit(WeightInit.XAVIER).list()
|
||||||
.layer(0, new OutputLayer.Builder().nIn(4).nOut(3)
|
.layer(0, new OutputLayer.Builder().nIn(4).nOut(3)
|
||||||
|
@ -123,7 +123,7 @@ public class TestEarlyStoppingSpark extends BaseSparkTest {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345)
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().seed(12345)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.updater(new Sgd(10.0)) //Intentionally huge LR
|
.updater(new Sgd(10.0)) //Intentionally huge LR
|
||||||
.weightInit(WeightInit.XAVIER).list()
|
.weightInit(WeightInit.XAVIER).list()
|
||||||
|
@ -163,7 +163,7 @@ public class TestEarlyStoppingSpark extends BaseSparkTest {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345)
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().seed(12345)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.updater(new Sgd(1e-6)).weightInit(WeightInit.XAVIER).list()
|
.updater(new Sgd(1e-6)).weightInit(WeightInit.XAVIER).list()
|
||||||
.layer(0, new OutputLayer.Builder().nIn(4).nOut(3)
|
.layer(0, new OutputLayer.Builder().nIn(4).nOut(3)
|
||||||
|
@ -209,7 +209,7 @@ public class TestEarlyStoppingSpark extends BaseSparkTest {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345)
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().seed(12345)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.updater(new Sgd(0.0)).weightInit(WeightInit.XAVIER).list()
|
.updater(new Sgd(0.0)).weightInit(WeightInit.XAVIER).list()
|
||||||
.layer(0, new OutputLayer.Builder().nIn(4).nOut(3)
|
.layer(0, new OutputLayer.Builder().nIn(4).nOut(3)
|
||||||
|
@ -246,7 +246,7 @@ public class TestEarlyStoppingSpark extends BaseSparkTest {
|
||||||
//Spark tests don't run on windows
|
//Spark tests don't run on windows
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.updater(new Sgd()).weightInit(WeightInit.XAVIER).list()
|
.updater(new Sgd()).weightInit(WeightInit.XAVIER).list()
|
||||||
.layer(0, new OutputLayer.Builder().nIn(4).nOut(3)
|
.layer(0, new OutputLayer.Builder().nIn(4).nOut(3)
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class TestEarlyStoppingSparkCompGraph extends BaseSparkTest {
|
||||||
//Spark tests don't run on windows
|
//Spark tests don't run on windows
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder()
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.updater(new Sgd()).weightInit(WeightInit.XAVIER).graphBuilder().addInputs("in")
|
.updater(new Sgd()).weightInit(WeightInit.XAVIER).graphBuilder().addInputs("in")
|
||||||
.addLayer("0", new OutputLayer.Builder().nIn(4).nOut(3)
|
.addLayer("0", new OutputLayer.Builder().nIn(4).nOut(3)
|
||||||
|
@ -124,7 +124,7 @@ public class TestEarlyStoppingSparkCompGraph extends BaseSparkTest {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345)
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder().seed(12345)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.updater(new Sgd(2.0)) //Intentionally huge LR
|
.updater(new Sgd(2.0)) //Intentionally huge LR
|
||||||
.weightInit(WeightInit.XAVIER).graphBuilder().addInputs("in")
|
.weightInit(WeightInit.XAVIER).graphBuilder().addInputs("in")
|
||||||
|
@ -165,7 +165,7 @@ public class TestEarlyStoppingSparkCompGraph extends BaseSparkTest {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345)
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder().seed(12345)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.updater(new Sgd(1e-6)).weightInit(WeightInit.XAVIER).graphBuilder()
|
.updater(new Sgd(1e-6)).weightInit(WeightInit.XAVIER).graphBuilder()
|
||||||
.addInputs("in")
|
.addInputs("in")
|
||||||
|
@ -213,7 +213,7 @@ public class TestEarlyStoppingSparkCompGraph extends BaseSparkTest {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345)
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder().seed(12345)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.updater(new Sgd(0.0)).weightInit(WeightInit.XAVIER).graphBuilder()
|
.updater(new Sgd(0.0)).weightInit(WeightInit.XAVIER).graphBuilder()
|
||||||
.addInputs("in")
|
.addInputs("in")
|
||||||
|
@ -253,7 +253,7 @@ public class TestEarlyStoppingSparkCompGraph extends BaseSparkTest {
|
||||||
//Spark tests don't run on windows
|
//Spark tests don't run on windows
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder()
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.updater(new Sgd()).weightInit(WeightInit.XAVIER).graphBuilder().addInputs("in")
|
.updater(new Sgd()).weightInit(WeightInit.XAVIER).graphBuilder().addInputs("in")
|
||||||
.addLayer("0", new OutputLayer.Builder().nIn(4).nOut(3)
|
.addLayer("0", new OutputLayer.Builder().nIn(4).nOut(3)
|
||||||
|
|
|
@ -22,7 +22,7 @@ package org.deeplearning4j.spark;
|
||||||
|
|
||||||
import org.apache.spark.serializer.SerializerInstance;
|
import org.apache.spark.serializer.SerializerInstance;
|
||||||
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.distribution.UniformDistribution;
|
import org.deeplearning4j.nn.conf.distribution.UniformDistribution;
|
||||||
import org.deeplearning4j.nn.conf.graph.*;
|
import org.deeplearning4j.nn.conf.graph.*;
|
||||||
|
@ -68,14 +68,14 @@ public class TestKryo extends BaseSparkKryoTest {
|
||||||
Map<Integer, Double> m = new HashMap<>();
|
Map<Integer, Double> m = new HashMap<>();
|
||||||
m.put(0, 0.5);
|
m.put(0, 0.5);
|
||||||
m.put(10, 0.1);
|
m.put(10, 0.1);
|
||||||
MultiLayerConfiguration mlc = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration mlc = NeuralNetConfiguration.builder()
|
||||||
.updater(new Nadam(new MapSchedule(ScheduleType.ITERATION,m))).list().layer(0, new OutputLayer.Builder().nIn(10).nOut(10).build())
|
.updater(new Nadam(new MapSchedule(ScheduleType.ITERATION,m))).list().layer(0, new OutputLayer.Builder().nIn(10).nOut(10).build())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
testSerialization(mlc, si);
|
testSerialization(mlc, si);
|
||||||
|
|
||||||
|
|
||||||
ComputationGraphConfiguration cgc = new NeuralNetConfiguration.Builder()
|
ComputationGraphConfiguration cgc = NeuralNetConfiguration.builder()
|
||||||
.dist(new UniformDistribution(-1, 1))
|
.dist(new UniformDistribution(-1, 1))
|
||||||
.updater(new Adam(new MapSchedule(ScheduleType.ITERATION,m)))
|
.updater(new Adam(new MapSchedule(ScheduleType.ITERATION,m)))
|
||||||
.graphBuilder()
|
.graphBuilder()
|
||||||
|
|
|
@ -30,7 +30,7 @@ import org.datavec.api.records.reader.impl.csv.CSVRecordReader;
|
||||||
import org.deeplearning4j.datasets.iterator.impl.IrisDataSetIterator;
|
import org.deeplearning4j.datasets.iterator.impl.IrisDataSetIterator;
|
||||||
import org.deeplearning4j.nn.api.OptimizationAlgorithm;
|
import org.deeplearning4j.nn.api.OptimizationAlgorithm;
|
||||||
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.Updater;
|
import org.deeplearning4j.nn.conf.Updater;
|
||||||
import org.deeplearning4j.spark.BaseSparkTest;
|
import org.deeplearning4j.spark.BaseSparkTest;
|
||||||
|
@ -84,7 +84,7 @@ public class TestPreProcessedData extends BaseSparkTest {
|
||||||
iter.next().save(f2);
|
iter.next().save(f2);
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().updater(Updater.RMSPROP)
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().updater(Updater.RMSPROP)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).list()
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).list()
|
||||||
.layer(0, new org.deeplearning4j.nn.conf.layers.DenseLayer.Builder().nIn(4).nOut(3)
|
.layer(0, new org.deeplearning4j.nn.conf.layers.DenseLayer.Builder().nIn(4).nOut(3)
|
||||||
.activation(Activation.TANH).build())
|
.activation(Activation.TANH).build())
|
||||||
|
@ -134,7 +134,7 @@ public class TestPreProcessedData extends BaseSparkTest {
|
||||||
iter.next().save(f2);
|
iter.next().save(f2);
|
||||||
}
|
}
|
||||||
|
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().updater(Updater.RMSPROP)
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder().updater(Updater.RMSPROP)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.graphBuilder().addInputs("in")
|
.graphBuilder().addInputs("in")
|
||||||
.addLayer("0", new org.deeplearning4j.nn.conf.layers.DenseLayer.Builder().nIn(4).nOut(3)
|
.addLayer("0", new org.deeplearning4j.nn.conf.layers.DenseLayer.Builder().nIn(4).nOut(3)
|
||||||
|
@ -188,7 +188,7 @@ public class TestPreProcessedData extends BaseSparkTest {
|
||||||
mds.save(f2);
|
mds.save(f2);
|
||||||
}
|
}
|
||||||
|
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().updater(Updater.RMSPROP)
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder().updater(Updater.RMSPROP)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.graphBuilder().addInputs("in")
|
.graphBuilder().addInputs("in")
|
||||||
.addLayer("0", new org.deeplearning4j.nn.conf.layers.DenseLayer.Builder().nIn(4).nOut(3)
|
.addLayer("0", new org.deeplearning4j.nn.conf.layers.DenseLayer.Builder().nIn(4).nOut(3)
|
||||||
|
|
|
@ -23,7 +23,7 @@ package org.deeplearning4j.spark.impl;
|
||||||
import org.apache.spark.SparkConf;
|
import org.apache.spark.SparkConf;
|
||||||
import org.apache.spark.api.java.JavaSparkContext;
|
import org.apache.spark.api.java.JavaSparkContext;
|
||||||
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.layers.OutputLayer;
|
import org.deeplearning4j.nn.conf.layers.OutputLayer;
|
||||||
import org.deeplearning4j.spark.api.TrainingMaster;
|
import org.deeplearning4j.spark.api.TrainingMaster;
|
||||||
|
@ -40,7 +40,7 @@ public class TestKryoWarning {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().list()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().list()
|
||||||
.layer(0, new OutputLayer.Builder().nIn(10).nOut(10).build())
|
.layer(0, new OutputLayer.Builder().nIn(10).nOut(10).build())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ public class TestKryoWarning {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().graphBuilder().addInputs("in")
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder().graphBuilder().addInputs("in")
|
||||||
.addLayer("0", new OutputLayer.Builder().nIn(10).nOut(10).build(), "in").setOutputs("0")
|
.addLayer("0", new OutputLayer.Builder().nIn(10).nOut(10).build(), "in").setOutputs("0")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ package org.deeplearning4j.spark.impl.customlayer;
|
||||||
|
|
||||||
import com.sun.jna.Platform;
|
import com.sun.jna.Platform;
|
||||||
import org.apache.spark.api.java.JavaRDD;
|
import org.apache.spark.api.java.JavaRDD;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.layers.DenseLayer;
|
import org.deeplearning4j.nn.conf.layers.DenseLayer;
|
||||||
import org.deeplearning4j.nn.conf.layers.OutputLayer;
|
import org.deeplearning4j.nn.conf.layers.OutputLayer;
|
||||||
|
@ -51,8 +51,8 @@ public class TestCustomLayer extends BaseSparkTest {
|
||||||
}
|
}
|
||||||
//Basic test - checks whether exceptions etc are thrown with custom layers + spark
|
//Basic test - checks whether exceptions etc are thrown with custom layers + spark
|
||||||
//Custom layers are tested more extensively in dl4j core
|
//Custom layers are tested more extensively in dl4j core
|
||||||
MultiLayerConfiguration conf =
|
NeuralNetConfiguration conf =
|
||||||
new NeuralNetConfiguration.Builder().updater(new Sgd(0.1)).list()
|
NeuralNetConfiguration.builder().updater(new Sgd(0.1)).list()
|
||||||
.layer(0, new DenseLayer.Builder().nIn(10).nOut(10).build())
|
.layer(0, new DenseLayer.Builder().nIn(10).nOut(10).build())
|
||||||
.layer(1, new CustomLayer(3.14159)).layer(2,
|
.layer(1, new CustomLayer(3.14159)).layer(2,
|
||||||
new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
||||||
|
|
|
@ -77,7 +77,7 @@ public class TestSparkComputationGraph extends BaseSparkTest {
|
||||||
|
|
||||||
public static ComputationGraph getBasicNetIris2Class() {
|
public static ComputationGraph getBasicNetIris2Class() {
|
||||||
|
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().weightInit(WeightInit.XAVIER)
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder().weightInit(WeightInit.XAVIER)
|
||||||
.graphBuilder().addInputs("in")
|
.graphBuilder().addInputs("in")
|
||||||
.addLayer("l0", new DenseLayer.Builder().nIn(4).nOut(10).build(), "in")
|
.addLayer("l0", new DenseLayer.Builder().nIn(4).nOut(10).build(), "in")
|
||||||
.addLayer("l1", new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
.addLayer("l1", new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
||||||
|
@ -104,7 +104,7 @@ public class TestSparkComputationGraph extends BaseSparkTest {
|
||||||
while (iter.hasNext())
|
while (iter.hasNext())
|
||||||
list.add(iter.next());
|
list.add(iter.next());
|
||||||
|
|
||||||
ComputationGraphConfiguration config = new NeuralNetConfiguration.Builder()
|
ComputationGraphConfiguration config = NeuralNetConfiguration.builder()
|
||||||
.updater(new Sgd(0.1))
|
.updater(new Sgd(0.1))
|
||||||
.graphBuilder().addInputs("in")
|
.graphBuilder().addInputs("in")
|
||||||
.addLayer("dense", new DenseLayer.Builder().nIn(4).nOut(2).build(), "in").addLayer("out",
|
.addLayer("dense", new DenseLayer.Builder().nIn(4).nOut(2).build(), "in").addLayer("out",
|
||||||
|
@ -138,7 +138,7 @@ public class TestSparkComputationGraph extends BaseSparkTest {
|
||||||
@Test
|
@Test
|
||||||
public void testDistributedScoring() {
|
public void testDistributedScoring() {
|
||||||
|
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().l1(0.1).l2(0.1)
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder().l1(0.1).l2(0.1)
|
||||||
.seed(123).updater(new Nesterovs(0.1, 0.9)).graphBuilder()
|
.seed(123).updater(new Nesterovs(0.1, 0.9)).graphBuilder()
|
||||||
.addInputs("in")
|
.addInputs("in")
|
||||||
.addLayer("0", new org.deeplearning4j.nn.conf.layers.DenseLayer.Builder().nIn(nIn).nOut(3)
|
.addLayer("0", new org.deeplearning4j.nn.conf.layers.DenseLayer.Builder().nIn(nIn).nOut(3)
|
||||||
|
@ -217,7 +217,7 @@ public class TestSparkComputationGraph extends BaseSparkTest {
|
||||||
//@Ignore("AB 2019/05/23 - Failing on CI only - passing locally. Possible precision or threading issue")
|
//@Ignore("AB 2019/05/23 - Failing on CI only - passing locally. Possible precision or threading issue")
|
||||||
public void testSeedRepeatability() throws Exception {
|
public void testSeedRepeatability() throws Exception {
|
||||||
|
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345).updater(Updater.RMSPROP)
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder().seed(12345).updater(Updater.RMSPROP)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.weightInit(WeightInit.XAVIER).graphBuilder().addInputs("in")
|
.weightInit(WeightInit.XAVIER).graphBuilder().addInputs("in")
|
||||||
.addLayer("0", new org.deeplearning4j.nn.conf.layers.DenseLayer.Builder().nIn(4).nOut(4)
|
.addLayer("0", new org.deeplearning4j.nn.conf.layers.DenseLayer.Builder().nIn(4).nOut(4)
|
||||||
|
@ -414,7 +414,7 @@ public class TestSparkComputationGraph extends BaseSparkTest {
|
||||||
JavaRDD<org.nd4j.linalg.dataset.api.MultiDataSet> rdd = sc.parallelize(l);
|
JavaRDD<org.nd4j.linalg.dataset.api.MultiDataSet> rdd = sc.parallelize(l);
|
||||||
|
|
||||||
// simple model
|
// simple model
|
||||||
val modelConf = new NeuralNetConfiguration.Builder()
|
val modelConf = NeuralNetConfiguration.builder()
|
||||||
.updater(new Adam(0.01))
|
.updater(new Adam(0.01))
|
||||||
.weightInit(WeightInit.XAVIER_UNIFORM)
|
.weightInit(WeightInit.XAVIER_UNIFORM)
|
||||||
.biasInit(0)
|
.biasInit(0)
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class TestFrozenLayers extends BaseSparkTest {
|
||||||
@Test
|
@Test
|
||||||
public void testSparkFrozenLayers() {
|
public void testSparkFrozenLayers() {
|
||||||
|
|
||||||
NeuralNetConfiguration.Builder overallConf = new NeuralNetConfiguration.Builder().updater(new Sgd(0.1))
|
NeuralNetConfiguration.NeuralNetConfigurationBuilder overallConf = NeuralNetConfiguration.builder().updater(new Sgd(0.1))
|
||||||
.activation(Activation.TANH);
|
.activation(Activation.TANH);
|
||||||
|
|
||||||
FineTuneConfiguration finetune = new FineTuneConfiguration.Builder().updater(new Sgd(0.1)).build();
|
FineTuneConfiguration finetune = new FineTuneConfiguration.Builder().updater(new Sgd(0.1)).build();
|
||||||
|
@ -136,7 +136,7 @@ public class TestFrozenLayers extends BaseSparkTest {
|
||||||
int nIn = 6;
|
int nIn = 6;
|
||||||
int nOut = 3;
|
int nOut = 3;
|
||||||
|
|
||||||
ComputationGraph origModel = new ComputationGraph(new NeuralNetConfiguration.Builder().updater(new Sgd(0.1))
|
ComputationGraph origModel = new ComputationGraph(NeuralNetConfiguration.builder().updater(new Sgd(0.1))
|
||||||
.activation(Activation.TANH).graphBuilder().addInputs("in")
|
.activation(Activation.TANH).graphBuilder().addInputs("in")
|
||||||
.addLayer("0", new DenseLayer.Builder().nIn(6).nOut(5).build(), "in")
|
.addLayer("0", new DenseLayer.Builder().nIn(6).nOut(5).build(), "in")
|
||||||
.addLayer("1", new DenseLayer.Builder().nIn(5).nOut(4).build(), "0")
|
.addLayer("1", new DenseLayer.Builder().nIn(5).nOut(4).build(), "0")
|
||||||
|
|
|
@ -23,7 +23,7 @@ package org.deeplearning4j.spark.impl.multilayer;
|
||||||
import org.apache.spark.api.java.JavaPairRDD;
|
import org.apache.spark.api.java.JavaPairRDD;
|
||||||
import org.deeplearning4j.datasets.iterator.impl.IrisDataSetIterator;
|
import org.deeplearning4j.datasets.iterator.impl.IrisDataSetIterator;
|
||||||
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.layers.*;
|
import org.deeplearning4j.nn.conf.layers.*;
|
||||||
import org.deeplearning4j.nn.conf.layers.variational.GaussianReconstructionDistribution;
|
import org.deeplearning4j.nn.conf.layers.variational.GaussianReconstructionDistribution;
|
||||||
|
@ -57,7 +57,7 @@ public class TestMiscFunctions extends BaseSparkTest {
|
||||||
@Test
|
@Test
|
||||||
public void testFeedForwardWithKey() {
|
public void testFeedForwardWithKey() {
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().weightInit(WeightInit.XAVIER).list()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().weightInit(WeightInit.XAVIER).list()
|
||||||
.layer(0, new DenseLayer.Builder().nIn(4).nOut(3).build())
|
.layer(0, new DenseLayer.Builder().nIn(4).nOut(3).build())
|
||||||
.layer(1, new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT).nIn(3).nOut(3)
|
.layer(1, new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT).nIn(3).nOut(3)
|
||||||
.activation(Activation.SOFTMAX).build())
|
.activation(Activation.SOFTMAX).build())
|
||||||
|
@ -107,7 +107,7 @@ public class TestMiscFunctions extends BaseSparkTest {
|
||||||
@Test
|
@Test
|
||||||
public void testFeedForwardWithKeyInputMask() {
|
public void testFeedForwardWithKeyInputMask() {
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().weightInit(WeightInit.XAVIER)
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().weightInit(WeightInit.XAVIER)
|
||||||
.list()
|
.list()
|
||||||
.layer( new LSTM.Builder().nIn(4).nOut(3).build())
|
.layer( new LSTM.Builder().nIn(4).nOut(3).build())
|
||||||
.layer(new GlobalPoolingLayer(PoolingType.AVG))
|
.layer(new GlobalPoolingLayer(PoolingType.AVG))
|
||||||
|
@ -162,7 +162,7 @@ public class TestMiscFunctions extends BaseSparkTest {
|
||||||
@Test
|
@Test
|
||||||
public void testFeedForwardWithKeyGraph() {
|
public void testFeedForwardWithKeyGraph() {
|
||||||
|
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().weightInit(WeightInit.XAVIER)
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder().weightInit(WeightInit.XAVIER)
|
||||||
.graphBuilder().addInputs("in1", "in2")
|
.graphBuilder().addInputs("in1", "in2")
|
||||||
.addLayer("0", new DenseLayer.Builder().nIn(4).nOut(3).build(), "in1")
|
.addLayer("0", new DenseLayer.Builder().nIn(4).nOut(3).build(), "in1")
|
||||||
.addLayer("1", new DenseLayer.Builder().nIn(4).nOut(3).build(), "in2").addLayer("2",
|
.addLayer("1", new DenseLayer.Builder().nIn(4).nOut(3).build(), "in2").addLayer("2",
|
||||||
|
@ -220,7 +220,7 @@ public class TestMiscFunctions extends BaseSparkTest {
|
||||||
|
|
||||||
int nIn = 10;
|
int nIn = 10;
|
||||||
|
|
||||||
MultiLayerConfiguration mlc = new NeuralNetConfiguration.Builder().list()
|
NeuralNetConfiguration mlc = NeuralNetConfiguration.builder().list()
|
||||||
.layer(0, new org.deeplearning4j.nn.conf.layers.variational.VariationalAutoencoder.Builder()
|
.layer(0, new org.deeplearning4j.nn.conf.layers.variational.VariationalAutoencoder.Builder()
|
||||||
.reconstructionDistribution(
|
.reconstructionDistribution(
|
||||||
new GaussianReconstructionDistribution(Activation.IDENTITY))
|
new GaussianReconstructionDistribution(Activation.IDENTITY))
|
||||||
|
@ -259,7 +259,7 @@ public class TestMiscFunctions extends BaseSparkTest {
|
||||||
|
|
||||||
int nIn = 10;
|
int nIn = 10;
|
||||||
|
|
||||||
MultiLayerConfiguration mlc = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration mlc = NeuralNetConfiguration.builder()
|
||||||
.list().layer(0,
|
.list().layer(0,
|
||||||
new org.deeplearning4j.nn.conf.layers.variational.VariationalAutoencoder.Builder()
|
new org.deeplearning4j.nn.conf.layers.variational.VariationalAutoencoder.Builder()
|
||||||
.reconstructionDistribution(new LossFunctionWrapper(
|
.reconstructionDistribution(new LossFunctionWrapper(
|
||||||
|
|
|
@ -25,7 +25,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.spark.api.java.JavaRDD;
|
import org.apache.spark.api.java.JavaRDD;
|
||||||
import org.deeplearning4j.datasets.iterator.impl.MnistDataSetIterator;
|
import org.deeplearning4j.datasets.iterator.impl.MnistDataSetIterator;
|
||||||
import org.deeplearning4j.nn.api.OptimizationAlgorithm;
|
import org.deeplearning4j.nn.api.OptimizationAlgorithm;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.layers.DenseLayer;
|
import org.deeplearning4j.nn.conf.layers.DenseLayer;
|
||||||
import org.deeplearning4j.nn.conf.layers.OutputLayer;
|
import org.deeplearning4j.nn.conf.layers.OutputLayer;
|
||||||
|
@ -102,7 +102,7 @@ public class TestSparkDl4jMultiLayer extends BaseSparkTest {
|
||||||
|
|
||||||
//----------------------------------
|
//----------------------------------
|
||||||
//Create network configuration and conduct network training
|
//Create network configuration and conduct network training
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.FLOAT)
|
.dataType(DataType.FLOAT)
|
||||||
.seed(12345)
|
.seed(12345)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
|
|
|
@ -26,7 +26,7 @@ import org.apache.spark.api.java.JavaRDD;
|
||||||
import org.apache.spark.api.java.JavaSparkContext;
|
import org.apache.spark.api.java.JavaSparkContext;
|
||||||
import org.deeplearning4j.nn.api.OptimizationAlgorithm;
|
import org.deeplearning4j.nn.api.OptimizationAlgorithm;
|
||||||
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.inputs.InputType;
|
import org.deeplearning4j.nn.conf.inputs.InputType;
|
||||||
import org.deeplearning4j.nn.conf.layers.ConvolutionLayer;
|
import org.deeplearning4j.nn.conf.layers.ConvolutionLayer;
|
||||||
|
@ -63,9 +63,9 @@ public class TestCompareParameterAveragingSparkVsSingleMachine {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static MultiLayerConfiguration getConf(int seed, IUpdater updater) {
|
private static NeuralNetConfiguration getConf(int seed, IUpdater updater) {
|
||||||
Nd4j.getRandom().setSeed(seed);
|
Nd4j.getRandom().setSeed(seed);
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.weightInit(WeightInit.XAVIER).updater(updater).seed(seed).list()
|
.weightInit(WeightInit.XAVIER).updater(updater).seed(seed).list()
|
||||||
.layer(0, new DenseLayer.Builder().nIn(10).nOut(10).build()).layer(1, new OutputLayer.Builder()
|
.layer(0, new DenseLayer.Builder().nIn(10).nOut(10).build()).layer(1, new OutputLayer.Builder()
|
||||||
|
@ -74,9 +74,9 @@ public class TestCompareParameterAveragingSparkVsSingleMachine {
|
||||||
return conf;
|
return conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static MultiLayerConfiguration getConfCNN(int seed, IUpdater updater) {
|
private static NeuralNetConfiguration getConfCNN(int seed, IUpdater updater) {
|
||||||
Nd4j.getRandom().setSeed(seed);
|
Nd4j.getRandom().setSeed(seed);
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.weightInit(WeightInit.XAVIER).updater(updater).seed(seed).list()
|
.weightInit(WeightInit.XAVIER).updater(updater).seed(seed).list()
|
||||||
.layer(0, new ConvolutionLayer.Builder().nOut(3).kernelSize(2, 2).stride(1, 1).padding(0, 0)
|
.layer(0, new ConvolutionLayer.Builder().nOut(3).kernelSize(2, 2).stride(1, 1).padding(0, 0)
|
||||||
|
@ -85,13 +85,13 @@ public class TestCompareParameterAveragingSparkVsSingleMachine {
|
||||||
.activation(Activation.TANH).build())
|
.activation(Activation.TANH).build())
|
||||||
.layer(1, new OutputLayer.Builder().lossFunction(LossFunctions.LossFunction.MSE).nOut(10)
|
.layer(1, new OutputLayer.Builder().lossFunction(LossFunctions.LossFunction.MSE).nOut(10)
|
||||||
.build())
|
.build())
|
||||||
.setInputType(InputType.convolutional(10, 10, 3)).build();
|
.inputType(InputType.convolutional(10, 10, 3)).build();
|
||||||
return conf;
|
return conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ComputationGraphConfiguration getGraphConf(int seed, IUpdater updater) {
|
private static ComputationGraphConfiguration getGraphConf(int seed, IUpdater updater) {
|
||||||
Nd4j.getRandom().setSeed(seed);
|
Nd4j.getRandom().setSeed(seed);
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder()
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.weightInit(WeightInit.XAVIER).updater(updater).seed(seed).graphBuilder()
|
.weightInit(WeightInit.XAVIER).updater(updater).seed(seed).graphBuilder()
|
||||||
.addInputs("in")
|
.addInputs("in")
|
||||||
|
@ -105,7 +105,7 @@ public class TestCompareParameterAveragingSparkVsSingleMachine {
|
||||||
|
|
||||||
private static ComputationGraphConfiguration getGraphConfCNN(int seed, IUpdater updater) {
|
private static ComputationGraphConfiguration getGraphConfCNN(int seed, IUpdater updater) {
|
||||||
Nd4j.getRandom().setSeed(seed);
|
Nd4j.getRandom().setSeed(seed);
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder()
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.weightInit(WeightInit.XAVIER).updater(updater).seed(seed).graphBuilder()
|
.weightInit(WeightInit.XAVIER).updater(updater).seed(seed).graphBuilder()
|
||||||
.addInputs("in")
|
.addInputs("in")
|
||||||
|
|
|
@ -37,7 +37,7 @@ import org.deeplearning4j.datasets.iterator.impl.MnistDataSetIterator;
|
||||||
import org.deeplearning4j.nn.api.Layer;
|
import org.deeplearning4j.nn.api.Layer;
|
||||||
import org.deeplearning4j.nn.api.OptimizationAlgorithm;
|
import org.deeplearning4j.nn.api.OptimizationAlgorithm;
|
||||||
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.layers.BaseLayer;
|
import org.deeplearning4j.nn.conf.layers.BaseLayer;
|
||||||
import org.deeplearning4j.nn.conf.layers.BatchNormalization;
|
import org.deeplearning4j.nn.conf.layers.BatchNormalization;
|
||||||
|
@ -127,7 +127,7 @@ public class TestSparkMultiLayerParameterAveraging extends BaseSparkTest {
|
||||||
.toJavaRDD().map(new TestFn());
|
.toJavaRDD().map(new TestFn());
|
||||||
|
|
||||||
DataSet d = new IrisDataSetIterator(150, 150).next();
|
DataSet d = new IrisDataSetIterator(150, 150).next();
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().seed(123)
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().seed(123)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).list()
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).list()
|
||||||
.layer(0, new DenseLayer.Builder().nIn(4).nOut(100).weightInit(WeightInit.XAVIER)
|
.layer(0, new DenseLayer.Builder().nIn(4).nOut(100).weightInit(WeightInit.XAVIER)
|
||||||
.activation(Activation.RELU).build())
|
.activation(Activation.RELU).build())
|
||||||
|
@ -162,8 +162,8 @@ public class TestSparkMultiLayerParameterAveraging extends BaseSparkTest {
|
||||||
.getAbsolutePath())
|
.getAbsolutePath())
|
||||||
.toJavaRDD().map(new TestFn());
|
.toJavaRDD().map(new TestFn());
|
||||||
|
|
||||||
MultiLayerConfiguration conf =
|
NeuralNetConfiguration conf =
|
||||||
new NeuralNetConfiguration.Builder().seed(123)
|
NeuralNetConfiguration.builder().seed(123)
|
||||||
.updater(new Adam(1e-6))
|
.updater(new Adam(1e-6))
|
||||||
.weightInit(WeightInit.XAVIER)
|
.weightInit(WeightInit.XAVIER)
|
||||||
.list()
|
.list()
|
||||||
|
@ -275,7 +275,7 @@ public class TestSparkMultiLayerParameterAveraging extends BaseSparkTest {
|
||||||
//Spark tests don't run on windows
|
//Spark tests don't run on windows
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().updater(new RmsProp())
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().updater(new RmsProp())
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).list()
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).list()
|
||||||
.layer(0, new org.deeplearning4j.nn.conf.layers.DenseLayer.Builder().nIn(nIn).nOut(3)
|
.layer(0, new org.deeplearning4j.nn.conf.layers.DenseLayer.Builder().nIn(nIn).nOut(3)
|
||||||
.activation(Activation.TANH).build())
|
.activation(Activation.TANH).build())
|
||||||
|
@ -300,7 +300,7 @@ public class TestSparkMultiLayerParameterAveraging extends BaseSparkTest {
|
||||||
@Test
|
@Test
|
||||||
public void testDistributedScoring() {
|
public void testDistributedScoring() {
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().l1(0.1).l2(0.1)
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().l1(0.1).l2(0.1)
|
||||||
.seed(123).updater(new Nesterovs(0.1, 0.9)).list()
|
.seed(123).updater(new Nesterovs(0.1, 0.9)).list()
|
||||||
.layer(0, new org.deeplearning4j.nn.conf.layers.DenseLayer.Builder().nIn(nIn).nOut(3)
|
.layer(0, new org.deeplearning4j.nn.conf.layers.DenseLayer.Builder().nIn(nIn).nOut(3)
|
||||||
.activation(Activation.TANH).build())
|
.activation(Activation.TANH).build())
|
||||||
|
@ -389,7 +389,7 @@ public class TestSparkMultiLayerParameterAveraging extends BaseSparkTest {
|
||||||
list.add(iter.next());
|
list.add(iter.next());
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().updater(new RmsProp())
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().updater(new RmsProp())
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).list()
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).list()
|
||||||
.layer(0, new org.deeplearning4j.nn.conf.layers.DenseLayer.Builder().nIn(28 * 28).nOut(50)
|
.layer(0, new org.deeplearning4j.nn.conf.layers.DenseLayer.Builder().nIn(28 * 28).nOut(50)
|
||||||
.activation(Activation.TANH).build())
|
.activation(Activation.TANH).build())
|
||||||
|
@ -453,7 +453,7 @@ public class TestSparkMultiLayerParameterAveraging extends BaseSparkTest {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().updater(new RmsProp())
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().updater(new RmsProp())
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).list()
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).list()
|
||||||
.layer(0, new org.deeplearning4j.nn.conf.layers.DenseLayer.Builder().nIn(28 * 28).nOut(50)
|
.layer(0, new org.deeplearning4j.nn.conf.layers.DenseLayer.Builder().nIn(28 * 28).nOut(50)
|
||||||
.activation(Activation.TANH).build())
|
.activation(Activation.TANH).build())
|
||||||
|
@ -523,7 +523,7 @@ public class TestSparkMultiLayerParameterAveraging extends BaseSparkTest {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().updater(new RmsProp())
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().updater(new RmsProp())
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).list()
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).list()
|
||||||
.layer(0, new org.deeplearning4j.nn.conf.layers.DenseLayer.Builder().nIn(28 * 28).nOut(50)
|
.layer(0, new org.deeplearning4j.nn.conf.layers.DenseLayer.Builder().nIn(28 * 28).nOut(50)
|
||||||
.activation(Activation.TANH).build())
|
.activation(Activation.TANH).build())
|
||||||
|
@ -611,7 +611,7 @@ public class TestSparkMultiLayerParameterAveraging extends BaseSparkTest {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().updater(new RmsProp())
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder().updater(new RmsProp())
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.graphBuilder().addInputs("in")
|
.graphBuilder().addInputs("in")
|
||||||
.addLayer("0", new org.deeplearning4j.nn.conf.layers.DenseLayer.Builder().nIn(28 * 28).nOut(50)
|
.addLayer("0", new org.deeplearning4j.nn.conf.layers.DenseLayer.Builder().nIn(28 * 28).nOut(50)
|
||||||
|
@ -684,7 +684,7 @@ public class TestSparkMultiLayerParameterAveraging extends BaseSparkTest {
|
||||||
//Spark tests don't run on windows
|
//Spark tests don't run on windows
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345).updater(new RmsProp())
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().seed(12345).updater(new RmsProp())
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.weightInit(WeightInit.XAVIER).list()
|
.weightInit(WeightInit.XAVIER).list()
|
||||||
.layer(0, new org.deeplearning4j.nn.conf.layers.DenseLayer.Builder().nIn(4).nOut(4)
|
.layer(0, new org.deeplearning4j.nn.conf.layers.DenseLayer.Builder().nIn(4).nOut(4)
|
||||||
|
@ -769,7 +769,7 @@ public class TestSparkMultiLayerParameterAveraging extends BaseSparkTest {
|
||||||
list.add(iter.next());
|
list.add(iter.next());
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().updater(new RmsProp())
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().updater(new RmsProp())
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).list()
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).list()
|
||||||
.layer(0, new org.deeplearning4j.nn.conf.layers.DenseLayer.Builder().nIn(28 * 28).nOut(50)
|
.layer(0, new org.deeplearning4j.nn.conf.layers.DenseLayer.Builder().nIn(28 * 28).nOut(50)
|
||||||
.activation(Activation.TANH).build())
|
.activation(Activation.TANH).build())
|
||||||
|
@ -791,13 +791,13 @@ public class TestSparkMultiLayerParameterAveraging extends BaseSparkTest {
|
||||||
|
|
||||||
JavaRDD<DataSet> rdd = sc.parallelize(list);
|
JavaRDD<DataSet> rdd = sc.parallelize(list);
|
||||||
|
|
||||||
assertEquals(0, sparkNet.getNetwork().getLayerWiseConfigurations().getIterationCount());
|
assertEquals(0, sparkNet.getNetwork().getConfiguration().getIterationCount());
|
||||||
sparkNet.fit(rdd);
|
sparkNet.fit(rdd);
|
||||||
assertEquals(minibatchesPerWorkerPerEpoch,
|
assertEquals(minibatchesPerWorkerPerEpoch,
|
||||||
sparkNet.getNetwork().getLayerWiseConfigurations().getIterationCount());
|
sparkNet.getNetwork().getConfiguration().getIterationCount());
|
||||||
sparkNet.fit(rdd);
|
sparkNet.fit(rdd);
|
||||||
assertEquals(2 * minibatchesPerWorkerPerEpoch,
|
assertEquals(2 * minibatchesPerWorkerPerEpoch,
|
||||||
sparkNet.getNetwork().getLayerWiseConfigurations().getIterationCount());
|
sparkNet.getNetwork().getConfiguration().getIterationCount());
|
||||||
|
|
||||||
sparkNet.getTrainingMaster().deleteTempFiles(sc);
|
sparkNet.getTrainingMaster().deleteTempFiles(sc);
|
||||||
}
|
}
|
||||||
|
@ -819,7 +819,7 @@ public class TestSparkMultiLayerParameterAveraging extends BaseSparkTest {
|
||||||
list.add(iter.next());
|
list.add(iter.next());
|
||||||
}
|
}
|
||||||
|
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().updater(new RmsProp())
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder().updater(new RmsProp())
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.graphBuilder().addInputs("in")
|
.graphBuilder().addInputs("in")
|
||||||
.addLayer("0", new org.deeplearning4j.nn.conf.layers.DenseLayer.Builder().nIn(28 * 28).nOut(50)
|
.addLayer("0", new org.deeplearning4j.nn.conf.layers.DenseLayer.Builder().nIn(28 * 28).nOut(50)
|
||||||
|
@ -860,7 +860,7 @@ public class TestSparkMultiLayerParameterAveraging extends BaseSparkTest {
|
||||||
int nIn = 8;
|
int nIn = 8;
|
||||||
|
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345).updater(new RmsProp())
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().seed(12345).updater(new RmsProp())
|
||||||
.weightInit(WeightInit.XAVIER).list()
|
.weightInit(WeightInit.XAVIER).list()
|
||||||
.layer(0, new VariationalAutoencoder.Builder().nIn(8).nOut(10).encoderLayerSizes(12)
|
.layer(0, new VariationalAutoencoder.Builder().nIn(8).nOut(10).encoderLayerSizes(12)
|
||||||
.decoderLayerSizes(13).reconstructionDistribution(
|
.decoderLayerSizes(13).reconstructionDistribution(
|
||||||
|
@ -896,7 +896,7 @@ public class TestSparkMultiLayerParameterAveraging extends BaseSparkTest {
|
||||||
int nIn = 8;
|
int nIn = 8;
|
||||||
|
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345).updater(new RmsProp())
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder().seed(12345).updater(new RmsProp())
|
||||||
.weightInit(WeightInit.XAVIER).graphBuilder().addInputs("in")
|
.weightInit(WeightInit.XAVIER).graphBuilder().addInputs("in")
|
||||||
.addLayer("0", new VariationalAutoencoder.Builder().nIn(8).nOut(10).encoderLayerSizes(12)
|
.addLayer("0", new VariationalAutoencoder.Builder().nIn(8).nOut(10).encoderLayerSizes(12)
|
||||||
.decoderLayerSizes(13).reconstructionDistribution(
|
.decoderLayerSizes(13).reconstructionDistribution(
|
||||||
|
@ -936,8 +936,8 @@ public class TestSparkMultiLayerParameterAveraging extends BaseSparkTest {
|
||||||
int nOut = 2;
|
int nOut = 2;
|
||||||
int layerSize = 10;
|
int layerSize = 10;
|
||||||
|
|
||||||
MultiLayerConfiguration conf =
|
NeuralNetConfiguration conf =
|
||||||
new NeuralNetConfiguration.Builder().weightInit(WeightInit.XAVIER).list()
|
NeuralNetConfiguration.builder().weightInit(WeightInit.XAVIER).list()
|
||||||
.layer(0, new DenseLayer.Builder().nIn(nIn).nOut(layerSize).build())
|
.layer(0, new DenseLayer.Builder().nIn(nIn).nOut(layerSize).build())
|
||||||
.layer(1, new OutputLayer.Builder().nIn(layerSize).nOut(nOut)
|
.layer(1, new OutputLayer.Builder().nIn(layerSize).nOut(nOut)
|
||||||
.activation(Activation.SOFTMAX).lossFunction(
|
.activation(Activation.SOFTMAX).lossFunction(
|
||||||
|
@ -991,8 +991,8 @@ public class TestSparkMultiLayerParameterAveraging extends BaseSparkTest {
|
||||||
int nOut = 3;
|
int nOut = 3;
|
||||||
int layerSize = 10;
|
int layerSize = 10;
|
||||||
|
|
||||||
MultiLayerConfiguration conf =
|
NeuralNetConfiguration conf =
|
||||||
new NeuralNetConfiguration.Builder().weightInit(WeightInit.XAVIER).list()
|
NeuralNetConfiguration.builder().weightInit(WeightInit.XAVIER).list()
|
||||||
.layer(0, new DenseLayer.Builder().nIn(nIn).nOut(layerSize).build())
|
.layer(0, new DenseLayer.Builder().nIn(nIn).nOut(layerSize).build())
|
||||||
.layer(1, new OutputLayer.Builder().nIn(layerSize).nOut(nOut)
|
.layer(1, new OutputLayer.Builder().nIn(layerSize).nOut(nOut)
|
||||||
.activation(Activation.SOFTMAX).lossFunction(
|
.activation(Activation.SOFTMAX).lossFunction(
|
||||||
|
@ -1045,12 +1045,12 @@ public class TestSparkMultiLayerParameterAveraging extends BaseSparkTest {
|
||||||
//Spark tests don't run on windows
|
//Spark tests don't run on windows
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.list()
|
.list()
|
||||||
.layer(new OutputLayer.Builder().nIn(4).nOut(3).build())
|
.layer(new OutputLayer.Builder().nIn(4).nOut(3).build())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
ComputationGraphConfiguration conf2 = new NeuralNetConfiguration.Builder()
|
ComputationGraphConfiguration conf2 = NeuralNetConfiguration.builder()
|
||||||
.graphBuilder()
|
.graphBuilder()
|
||||||
.addInputs("in")
|
.addInputs("in")
|
||||||
.addLayer("out", new OutputLayer.Builder().nIn(4).nOut(3).build(), "in")
|
.addLayer("out", new OutputLayer.Builder().nIn(4).nOut(3).build(), "in")
|
||||||
|
@ -1081,11 +1081,11 @@ public class TestSparkMultiLayerParameterAveraging extends BaseSparkTest {
|
||||||
|
|
||||||
|
|
||||||
for(int i=0; i<3; i++ ){
|
for(int i=0; i<3; i++ ){
|
||||||
assertEquals(i, sn1.getNetwork().getLayerWiseConfigurations().getEpochCount());
|
assertEquals(i, sn1.getNetwork().getConfiguration().getEpochCount());
|
||||||
assertEquals(i, sn2.getNetwork().getConfiguration().getEpochCount());
|
assertEquals(i, sn2.getNetwork().getConfiguration().getEpochCount());
|
||||||
sn1.fit(rdd);
|
sn1.fit(rdd);
|
||||||
sn2.fit(rdd);
|
sn2.fit(rdd);
|
||||||
assertEquals(i+1, sn1.getNetwork().getLayerWiseConfigurations().getEpochCount());
|
assertEquals(i+1, sn1.getNetwork().getConfiguration().getEpochCount());
|
||||||
assertEquals(i+1, sn2.getNetwork().getConfiguration().getEpochCount());
|
assertEquals(i+1, sn2.getNetwork().getConfiguration().getEpochCount());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ import org.apache.spark.SparkConf;
|
||||||
import org.apache.spark.api.java.JavaRDD;
|
import org.apache.spark.api.java.JavaRDD;
|
||||||
import org.apache.spark.api.java.JavaSparkContext;
|
import org.apache.spark.api.java.JavaSparkContext;
|
||||||
import org.deeplearning4j.nn.api.OptimizationAlgorithm;
|
import org.deeplearning4j.nn.api.OptimizationAlgorithm;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.layers.DenseLayer;
|
import org.deeplearning4j.nn.conf.layers.DenseLayer;
|
||||||
import org.deeplearning4j.nn.conf.layers.OutputLayer;
|
import org.deeplearning4j.nn.conf.layers.OutputLayer;
|
||||||
|
@ -67,7 +67,7 @@ public class TestTrainingStatsCollection extends BaseSparkTest {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).list()
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).list()
|
||||||
.layer(0, new DenseLayer.Builder().nIn(10).nOut(10).build())
|
.layer(0, new DenseLayer.Builder().nIn(10).nOut(10).build())
|
||||||
.layer(1, new OutputLayer.Builder().nIn(10).nOut(10).build())
|
.layer(1, new OutputLayer.Builder().nIn(10).nOut(10).build())
|
||||||
|
|
|
@ -27,7 +27,7 @@ import org.deeplearning4j.core.storage.Persistable;
|
||||||
import org.deeplearning4j.core.storage.StatsStorage;
|
import org.deeplearning4j.core.storage.StatsStorage;
|
||||||
import org.deeplearning4j.datasets.iterator.impl.IrisDataSetIterator;
|
import org.deeplearning4j.datasets.iterator.impl.IrisDataSetIterator;
|
||||||
import org.deeplearning4j.nn.api.OptimizationAlgorithm;
|
import org.deeplearning4j.nn.api.OptimizationAlgorithm;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.layers.DenseLayer;
|
import org.deeplearning4j.nn.conf.layers.DenseLayer;
|
||||||
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
||||||
|
@ -60,7 +60,7 @@ public class TestListeners extends BaseSparkTest {
|
||||||
JavaSparkContext sc = getContext();
|
JavaSparkContext sc = getContext();
|
||||||
int nExecutors = numExecutors();
|
int nExecutors = numExecutors();
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().seed(123)
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().seed(123)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).list()
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).list()
|
||||||
.layer(0, new DenseLayer.Builder().nIn(4).nOut(100).weightInit(WeightInit.XAVIER)
|
.layer(0, new DenseLayer.Builder().nIn(4).nOut(100).weightInit(WeightInit.XAVIER)
|
||||||
.activation(Activation.RELU).build())
|
.activation(Activation.RELU).build())
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
package org.deeplearning4j.rl4j.network;
|
package org.deeplearning4j.rl4j.network;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.gradient.Gradient;
|
import org.deeplearning4j.nn.gradient.Gradient;
|
||||||
import org.deeplearning4j.nn.layers.recurrent.RnnOutputLayer;
|
import org.deeplearning4j.nn.layers.recurrent.RnnOutputLayer;
|
||||||
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
||||||
|
@ -41,7 +41,7 @@ public class MultiLayerNetworkHandler implements INetworkHandler {
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final boolean recurrent;
|
private final boolean recurrent;
|
||||||
private final MultiLayerConfiguration configuration;
|
private final NeuralNetConfiguration configuration;
|
||||||
private final String labelName;
|
private final String labelName;
|
||||||
private final String gradientName;
|
private final String gradientName;
|
||||||
private final int inputFeatureIdx;
|
private final int inputFeatureIdx;
|
||||||
|
@ -59,7 +59,7 @@ public class MultiLayerNetworkHandler implements INetworkHandler {
|
||||||
int inputFeatureIdx) {
|
int inputFeatureIdx) {
|
||||||
this.model = model;
|
this.model = model;
|
||||||
recurrent = model.getOutputLayer() instanceof RnnOutputLayer;
|
recurrent = model.getOutputLayer() instanceof RnnOutputLayer;
|
||||||
configuration = model.getLayerWiseConfigurations();
|
configuration = model.getConfiguration();
|
||||||
this.labelName = labelName;
|
this.labelName = labelName;
|
||||||
this.gradientName = gradientName;
|
this.gradientName = gradientName;
|
||||||
this.inputFeatureIdx = inputFeatureIdx;
|
this.inputFeatureIdx = inputFeatureIdx;
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class ActorCriticFactoryCompGraphStdConv implements ActorCriticFactoryCom
|
||||||
int w = (((shapeInputs[2] - 8) / 4 + 1) - 4) / 2 + 1;
|
int w = (((shapeInputs[2] - 8) / 4 + 1) - 4) / 2 + 1;
|
||||||
|
|
||||||
ComputationGraphConfiguration.GraphBuilder confB =
|
ComputationGraphConfiguration.GraphBuilder confB =
|
||||||
new NeuralNetConfiguration.Builder().seed(Constants.NEURAL_NET_SEED)
|
NeuralNetConfiguration.builder().seed(Constants.NEURAL_NET_SEED)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.updater(conf.getUpdater() != null ? conf.getUpdater() : new Adam())
|
.updater(conf.getUpdater() != null ? conf.getUpdater() : new Adam())
|
||||||
.weightInit(WeightInit.XAVIER)
|
.weightInit(WeightInit.XAVIER)
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class ActorCriticFactoryCompGraphStdDense implements ActorCriticFactoryCo
|
||||||
nIn *= i;
|
nIn *= i;
|
||||||
}
|
}
|
||||||
ComputationGraphConfiguration.GraphBuilder confB =
|
ComputationGraphConfiguration.GraphBuilder confB =
|
||||||
new NeuralNetConfiguration.Builder().seed(Constants.NEURAL_NET_SEED)
|
NeuralNetConfiguration.builder().seed(Constants.NEURAL_NET_SEED)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.updater(conf.getUpdater() != null ? conf.getUpdater() : new Adam())
|
.updater(conf.getUpdater() != null ? conf.getUpdater() : new Adam())
|
||||||
.weightInit(WeightInit.XAVIER)
|
.weightInit(WeightInit.XAVIER)
|
||||||
|
|
|
@ -24,7 +24,7 @@ import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Value;
|
import lombok.Value;
|
||||||
import org.deeplearning4j.nn.api.OptimizationAlgorithm;
|
import org.deeplearning4j.nn.api.OptimizationAlgorithm;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.inputs.InputType;
|
import org.deeplearning4j.nn.conf.inputs.InputType;
|
||||||
import org.deeplearning4j.nn.conf.layers.DenseLayer;
|
import org.deeplearning4j.nn.conf.layers.DenseLayer;
|
||||||
|
@ -56,7 +56,7 @@ public class ActorCriticFactorySeparateStdDense implements ActorCriticFactorySep
|
||||||
for (int i : numInputs) {
|
for (int i : numInputs) {
|
||||||
nIn *= i;
|
nIn *= i;
|
||||||
}
|
}
|
||||||
NeuralNetConfiguration.ListBuilder confB = new NeuralNetConfiguration.Builder().seed(Constants.NEURAL_NET_SEED)
|
NeuralNetConfiguration.ListBuilder confB = NeuralNetConfiguration.builder().seed(Constants.NEURAL_NET_SEED)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.updater(conf.getUpdater() != null ? conf.getUpdater() : new Adam())
|
.updater(conf.getUpdater() != null ? conf.getUpdater() : new Adam())
|
||||||
.weightInit(WeightInit.XAVIER)
|
.weightInit(WeightInit.XAVIER)
|
||||||
|
@ -81,7 +81,7 @@ public class ActorCriticFactorySeparateStdDense implements ActorCriticFactorySep
|
||||||
}
|
}
|
||||||
|
|
||||||
confB.setInputType(conf.isUseLSTM() ? InputType.recurrent(nIn) : InputType.feedForward(nIn));
|
confB.setInputType(conf.isUseLSTM() ? InputType.recurrent(nIn) : InputType.feedForward(nIn));
|
||||||
MultiLayerConfiguration mlnconf2 = confB.build();
|
NeuralNetConfiguration mlnconf2 = confB.build();
|
||||||
MultiLayerNetwork model = new MultiLayerNetwork(mlnconf2);
|
MultiLayerNetwork model = new MultiLayerNetwork(mlnconf2);
|
||||||
model.init();
|
model.init();
|
||||||
if (conf.getListeners() != null) {
|
if (conf.getListeners() != null) {
|
||||||
|
@ -90,7 +90,7 @@ public class ActorCriticFactorySeparateStdDense implements ActorCriticFactorySep
|
||||||
model.setListeners(new ScoreIterationListener(Constants.NEURAL_NET_ITERATION_LISTENER));
|
model.setListeners(new ScoreIterationListener(Constants.NEURAL_NET_ITERATION_LISTENER));
|
||||||
}
|
}
|
||||||
|
|
||||||
NeuralNetConfiguration.ListBuilder confB2 = new NeuralNetConfiguration.Builder().seed(Constants.NEURAL_NET_SEED)
|
NeuralNetConfiguration.ListBuilder confB2 = NeuralNetConfiguration.builder().seed(Constants.NEURAL_NET_SEED)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.updater(conf.getUpdater() != null ? conf.getUpdater() : new Adam())
|
.updater(conf.getUpdater() != null ? conf.getUpdater() : new Adam())
|
||||||
.weightInit(WeightInit.XAVIER)
|
.weightInit(WeightInit.XAVIER)
|
||||||
|
@ -116,7 +116,7 @@ public class ActorCriticFactorySeparateStdDense implements ActorCriticFactorySep
|
||||||
}
|
}
|
||||||
|
|
||||||
confB2.setInputType(conf.isUseLSTM() ? InputType.recurrent(nIn) : InputType.feedForward(nIn));
|
confB2.setInputType(conf.isUseLSTM() ? InputType.recurrent(nIn) : InputType.feedForward(nIn));
|
||||||
MultiLayerConfiguration mlnconf = confB2.build();
|
NeuralNetConfiguration mlnconf = confB2.build();
|
||||||
MultiLayerNetwork model2 = new MultiLayerNetwork(mlnconf);
|
MultiLayerNetwork model2 = new MultiLayerNetwork(mlnconf);
|
||||||
model2.init();
|
model2.init();
|
||||||
if (conf.getListeners() != null) {
|
if (conf.getListeners() != null) {
|
||||||
|
|
|
@ -23,7 +23,7 @@ package org.deeplearning4j.rl4j.network.ac;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.apache.commons.lang3.NotImplementedException;
|
import org.apache.commons.lang3.NotImplementedException;
|
||||||
import org.deeplearning4j.nn.api.NeuralNetwork;
|
import org.deeplearning4j.nn.api.NeuralNetwork;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.gradient.Gradient;
|
import org.deeplearning4j.nn.gradient.Gradient;
|
||||||
import org.deeplearning4j.nn.layers.recurrent.RnnOutputLayer;
|
import org.deeplearning4j.nn.layers.recurrent.RnnOutputLayer;
|
||||||
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
||||||
|
@ -131,7 +131,7 @@ public class ActorCriticSeparate<NN extends ActorCriticSeparate> implements IAct
|
||||||
@Override
|
@Override
|
||||||
public void applyGradients(Gradients gradients) {
|
public void applyGradients(Gradients gradients) {
|
||||||
int batchSize = (int)gradients.getBatchSize();
|
int batchSize = (int)gradients.getBatchSize();
|
||||||
MultiLayerConfiguration valueConf = valueNet.getLayerWiseConfigurations();
|
NeuralNetConfiguration valueConf = valueNet.getConfiguration();
|
||||||
int valueIterationCount = valueConf.getIterationCount();
|
int valueIterationCount = valueConf.getIterationCount();
|
||||||
int valueEpochCount = valueConf.getEpochCount();
|
int valueEpochCount = valueConf.getEpochCount();
|
||||||
Gradient valueGradient = gradients.getGradient(CommonGradientNames.ActorCritic.Value);
|
Gradient valueGradient = gradients.getGradient(CommonGradientNames.ActorCritic.Value);
|
||||||
|
@ -145,7 +145,7 @@ public class ActorCriticSeparate<NN extends ActorCriticSeparate> implements IAct
|
||||||
}
|
}
|
||||||
valueConf.setIterationCount(valueIterationCount + 1);
|
valueConf.setIterationCount(valueIterationCount + 1);
|
||||||
|
|
||||||
MultiLayerConfiguration policyConf = policyNet.getLayerWiseConfigurations();
|
NeuralNetConfiguration policyConf = policyNet.getConfiguration();
|
||||||
int policyIterationCount = policyConf.getIterationCount();
|
int policyIterationCount = policyConf.getIterationCount();
|
||||||
int policyEpochCount = policyConf.getEpochCount();
|
int policyEpochCount = policyConf.getEpochCount();
|
||||||
Gradient policyGradient = gradients.getGradient(CommonGradientNames.ActorCritic.Policy);
|
Gradient policyGradient = gradients.getGradient(CommonGradientNames.ActorCritic.Policy);
|
||||||
|
@ -191,7 +191,7 @@ public class ActorCriticSeparate<NN extends ActorCriticSeparate> implements IAct
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void applyGradient(Gradient[] gradient, int batchSize) {
|
public void applyGradient(Gradient[] gradient, int batchSize) {
|
||||||
MultiLayerConfiguration valueConf = valueNet.getLayerWiseConfigurations();
|
NeuralNetConfiguration valueConf = valueNet.getConfiguration();
|
||||||
int valueIterationCount = valueConf.getIterationCount();
|
int valueIterationCount = valueConf.getIterationCount();
|
||||||
int valueEpochCount = valueConf.getEpochCount();
|
int valueEpochCount = valueConf.getEpochCount();
|
||||||
valueNet.getUpdater().update(valueNet, gradient[0], valueIterationCount, valueEpochCount, batchSize, LayerWorkspaceMgr.noWorkspaces());
|
valueNet.getUpdater().update(valueNet, gradient[0], valueIterationCount, valueEpochCount, batchSize, LayerWorkspaceMgr.noWorkspaces());
|
||||||
|
@ -204,7 +204,7 @@ public class ActorCriticSeparate<NN extends ActorCriticSeparate> implements IAct
|
||||||
}
|
}
|
||||||
valueConf.setIterationCount(valueIterationCount + 1);
|
valueConf.setIterationCount(valueIterationCount + 1);
|
||||||
|
|
||||||
MultiLayerConfiguration policyConf = policyNet.getLayerWiseConfigurations();
|
NeuralNetConfiguration policyConf = policyNet.getConfiguration();
|
||||||
int policyIterationCount = policyConf.getIterationCount();
|
int policyIterationCount = policyConf.getIterationCount();
|
||||||
int policyEpochCount = policyConf.getEpochCount();
|
int policyEpochCount = policyConf.getEpochCount();
|
||||||
policyNet.getUpdater().update(policyNet, gradient[1], policyIterationCount, policyEpochCount, batchSize, LayerWorkspaceMgr.noWorkspaces());
|
policyNet.getUpdater().update(policyNet, gradient[1], policyIterationCount, policyEpochCount, batchSize, LayerWorkspaceMgr.noWorkspaces());
|
||||||
|
|
|
@ -22,7 +22,7 @@ package org.deeplearning4j.rl4j.network.dqn;
|
||||||
|
|
||||||
import org.apache.commons.lang3.NotImplementedException;
|
import org.apache.commons.lang3.NotImplementedException;
|
||||||
import org.deeplearning4j.nn.api.NeuralNetwork;
|
import org.deeplearning4j.nn.api.NeuralNetwork;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.gradient.Gradient;
|
import org.deeplearning4j.nn.gradient.Gradient;
|
||||||
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
||||||
import org.deeplearning4j.nn.workspace.LayerWorkspaceMgr;
|
import org.deeplearning4j.nn.workspace.LayerWorkspaceMgr;
|
||||||
|
@ -157,7 +157,7 @@ public class DQN implements IDQN<DQN> {
|
||||||
public void applyGradients(Gradients gradients) {
|
public void applyGradients(Gradients gradients) {
|
||||||
Gradient qValues = gradients.getGradient(CommonGradientNames.QValues);
|
Gradient qValues = gradients.getGradient(CommonGradientNames.QValues);
|
||||||
|
|
||||||
MultiLayerConfiguration mlnConf = mln.getLayerWiseConfigurations();
|
NeuralNetConfiguration mlnConf = mln.getConfiguration();
|
||||||
int iterationCount = mlnConf.getIterationCount();
|
int iterationCount = mlnConf.getIterationCount();
|
||||||
int epochCount = mlnConf.getEpochCount();
|
int epochCount = mlnConf.getEpochCount();
|
||||||
mln.getUpdater().update(mln, qValues, iterationCount, epochCount, (int)gradients.getBatchSize(), LayerWorkspaceMgr.noWorkspaces());
|
mln.getUpdater().update(mln, qValues, iterationCount, epochCount, (int)gradients.getBatchSize(), LayerWorkspaceMgr.noWorkspaces());
|
||||||
|
@ -172,7 +172,7 @@ public class DQN implements IDQN<DQN> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void applyGradient(Gradient[] gradient, int batchSize) {
|
public void applyGradient(Gradient[] gradient, int batchSize) {
|
||||||
MultiLayerConfiguration mlnConf = mln.getLayerWiseConfigurations();
|
NeuralNetConfiguration mlnConf = mln.getConfiguration();
|
||||||
int iterationCount = mlnConf.getIterationCount();
|
int iterationCount = mlnConf.getIterationCount();
|
||||||
int epochCount = mlnConf.getEpochCount();
|
int epochCount = mlnConf.getEpochCount();
|
||||||
mln.getUpdater().update(mln, gradient[0], iterationCount, epochCount, batchSize, LayerWorkspaceMgr.noWorkspaces());
|
mln.getUpdater().update(mln, gradient[0], iterationCount, epochCount, batchSize, LayerWorkspaceMgr.noWorkspaces());
|
||||||
|
|
|
@ -24,7 +24,7 @@ import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Value;
|
import lombok.Value;
|
||||||
import org.deeplearning4j.nn.api.OptimizationAlgorithm;
|
import org.deeplearning4j.nn.api.OptimizationAlgorithm;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.inputs.InputType;
|
import org.deeplearning4j.nn.conf.inputs.InputType;
|
||||||
import org.deeplearning4j.nn.conf.layers.ConvolutionLayer;
|
import org.deeplearning4j.nn.conf.layers.ConvolutionLayer;
|
||||||
|
@ -55,7 +55,7 @@ public class DQNFactoryStdConv implements DQNFactory {
|
||||||
throw new AssertionError("Impossible to apply convolutional layer on a shape == 1");
|
throw new AssertionError("Impossible to apply convolutional layer on a shape == 1");
|
||||||
|
|
||||||
|
|
||||||
NeuralNetConfiguration.ListBuilder confB = new NeuralNetConfiguration.Builder().seed(Constants.NEURAL_NET_SEED)
|
NeuralNetConfiguration.ListBuilder confB = NeuralNetConfiguration.builder().seed(Constants.NEURAL_NET_SEED)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.l2(conf.getL2())
|
.l2(conf.getL2())
|
||||||
.updater(conf.getUpdater() != null ? conf.getUpdater() : new Adam())
|
.updater(conf.getUpdater() != null ? conf.getUpdater() : new Adam())
|
||||||
|
@ -71,8 +71,8 @@ public class DQNFactoryStdConv implements DQNFactory {
|
||||||
confB.layer(3, new OutputLayer.Builder(LossFunctions.LossFunction.MSE).activation(Activation.IDENTITY).nOut(numOutputs)
|
confB.layer(3, new OutputLayer.Builder(LossFunctions.LossFunction.MSE).activation(Activation.IDENTITY).nOut(numOutputs)
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
confB.setInputType(InputType.convolutional(shapeInputs[1], shapeInputs[2], shapeInputs[0]));
|
confB.inputType(InputType.convolutional(shapeInputs[1], shapeInputs[2], shapeInputs[0]));
|
||||||
MultiLayerConfiguration mlnconf = confB.build();
|
NeuralNetConfiguration mlnconf = confB.build();
|
||||||
MultiLayerNetwork model = new MultiLayerNetwork(mlnconf);
|
MultiLayerNetwork model = new MultiLayerNetwork(mlnconf);
|
||||||
model.init();
|
model.init();
|
||||||
if (conf.getListeners() != null) {
|
if (conf.getListeners() != null) {
|
||||||
|
|
|
@ -24,7 +24,7 @@ import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Value;
|
import lombok.Value;
|
||||||
import org.deeplearning4j.nn.api.OptimizationAlgorithm;
|
import org.deeplearning4j.nn.api.OptimizationAlgorithm;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.layers.DenseLayer;
|
import org.deeplearning4j.nn.conf.layers.DenseLayer;
|
||||||
import org.deeplearning4j.nn.conf.layers.OutputLayer;
|
import org.deeplearning4j.nn.conf.layers.OutputLayer;
|
||||||
|
@ -54,7 +54,7 @@ public class DQNFactoryStdDense implements DQNFactory {
|
||||||
nIn *= i;
|
nIn *= i;
|
||||||
}
|
}
|
||||||
|
|
||||||
NeuralNetConfiguration.ListBuilder confB = new NeuralNetConfiguration.Builder().seed(Constants.NEURAL_NET_SEED)
|
NeuralNetConfiguration.ListBuilder confB = NeuralNetConfiguration.builder().seed(Constants.NEURAL_NET_SEED)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.updater(conf.getUpdater() != null ? conf.getUpdater() : new Adam())
|
.updater(conf.getUpdater() != null ? conf.getUpdater() : new Adam())
|
||||||
.weightInit(WeightInit.XAVIER)
|
.weightInit(WeightInit.XAVIER)
|
||||||
|
@ -82,7 +82,7 @@ public class DQNFactoryStdDense implements DQNFactory {
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
MultiLayerConfiguration mlnconf = confB.build();
|
NeuralNetConfiguration mlnconf = confB.build();
|
||||||
MultiLayerNetwork model = new MultiLayerNetwork(mlnconf);
|
MultiLayerNetwork model = new MultiLayerNetwork(mlnconf);
|
||||||
model.init();
|
model.init();
|
||||||
if (conf.getListeners() != null) {
|
if (conf.getListeners() != null) {
|
||||||
|
|
|
@ -134,7 +134,7 @@ public class NStepRnn {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ComputationGraphConfiguration.GraphBuilder buildBaseNetworkConfiguration(int lstmLayerSize, int dl1Size, int dl2Size) {
|
private static ComputationGraphConfiguration.GraphBuilder buildBaseNetworkConfiguration(int lstmLayerSize, int dl1Size, int dl2Size) {
|
||||||
return new NeuralNetConfiguration.Builder().seed(Constants.NEURAL_NET_SEED)
|
return NeuralNetConfiguration.builder().seed(Constants.NEURAL_NET_SEED)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.updater(new Adam())
|
.updater(new Adam())
|
||||||
.weightInit(WeightInit.XAVIER)
|
.weightInit(WeightInit.XAVIER)
|
||||||
|
|
|
@ -188,7 +188,7 @@ public class RobotLakeExample {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ComputationGraphConfiguration.GraphBuilder buildBaseNetworkConfiguration() {
|
private static ComputationGraphConfiguration.GraphBuilder buildBaseNetworkConfiguration() {
|
||||||
return new NeuralNetConfiguration.Builder().seed(Constants.NEURAL_NET_SEED)
|
return NeuralNetConfiguration.builder().seed(Constants.NEURAL_NET_SEED)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.updater(new Adam())
|
.updater(new Adam())
|
||||||
.weightInit(WeightInit.XAVIER)
|
.weightInit(WeightInit.XAVIER)
|
||||||
|
|
|
@ -174,7 +174,7 @@ public class TMazeExample {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ComputationGraphConfiguration.GraphBuilder buildBaseNetworkConfiguration() {
|
private static ComputationGraphConfiguration.GraphBuilder buildBaseNetworkConfiguration() {
|
||||||
return new NeuralNetConfiguration.Builder().seed(Constants.NEURAL_NET_SEED)
|
return NeuralNetConfiguration.builder().seed(Constants.NEURAL_NET_SEED)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.updater(new Adam())
|
.updater(new Adam())
|
||||||
.weightInit(WeightInit.XAVIER)
|
.weightInit(WeightInit.XAVIER)
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
package org.deeplearning4j.rl4j.network;
|
package org.deeplearning4j.rl4j.network;
|
||||||
|
|
||||||
import org.deeplearning4j.nn.api.Updater;
|
import org.deeplearning4j.nn.api.Updater;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.gradient.Gradient;
|
import org.deeplearning4j.nn.gradient.Gradient;
|
||||||
import org.deeplearning4j.nn.layers.recurrent.RnnOutputLayer;
|
import org.deeplearning4j.nn.layers.recurrent.RnnOutputLayer;
|
||||||
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
||||||
|
@ -52,7 +52,7 @@ public class MultiLayerNetworkHandlerTest {
|
||||||
|
|
||||||
private MultiLayerNetwork modelMock;
|
private MultiLayerNetwork modelMock;
|
||||||
private TrainingListener trainingListenerMock;
|
private TrainingListener trainingListenerMock;
|
||||||
private MultiLayerConfiguration configurationMock;
|
private NeuralNetConfiguration configurationMock;
|
||||||
|
|
||||||
private MultiLayerNetworkHandler sut;
|
private MultiLayerNetworkHandler sut;
|
||||||
|
|
||||||
|
@ -60,10 +60,10 @@ public class MultiLayerNetworkHandlerTest {
|
||||||
modelMock = mock(MultiLayerNetwork.class);
|
modelMock = mock(MultiLayerNetwork.class);
|
||||||
trainingListenerMock = mock(TrainingListener.class);
|
trainingListenerMock = mock(TrainingListener.class);
|
||||||
|
|
||||||
configurationMock = mock(MultiLayerConfiguration.class);
|
configurationMock = mock(NeuralNetConfiguration.class);
|
||||||
when(configurationMock.getIterationCount()).thenReturn(123);
|
when(configurationMock.getIterationCount()).thenReturn(123);
|
||||||
when(configurationMock.getEpochCount()).thenReturn(234);
|
when(configurationMock.getEpochCount()).thenReturn(234);
|
||||||
when(modelMock.getLayerWiseConfigurations()).thenReturn(configurationMock);
|
when(modelMock.getConfiguration()).thenReturn(configurationMock);
|
||||||
|
|
||||||
if(setupRecurrent) {
|
if(setupRecurrent) {
|
||||||
when(modelMock.getOutputLayer()).thenReturn(new RnnOutputLayer(null, null));
|
when(modelMock.getOutputLayer()).thenReturn(new RnnOutputLayer(null, null));
|
||||||
|
|
|
@ -166,9 +166,9 @@ public class PolicyTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testACPolicy() throws Exception {
|
public void testACPolicy() throws Exception {
|
||||||
ComputationGraph cg = new ComputationGraph(new NeuralNetConfiguration.Builder().seed(444).graphBuilder().addInputs("input")
|
ComputationGraph cg = new ComputationGraph(NeuralNetConfiguration.builder().seed(444).graphBuilder().addInputs("input")
|
||||||
.addLayer("output", new OutputLayer.Builder().nOut(1).lossFunction(LossFunctions.LossFunction.XENT).activation(Activation.SIGMOID).build(), "input").setOutputs("output").build());
|
.addLayer("output", new OutputLayer.Builder().nOut(1).lossFunction(LossFunctions.LossFunction.XENT).activation(Activation.SIGMOID).build(), "input").setOutputs("output").build());
|
||||||
MultiLayerNetwork mln = new MultiLayerNetwork(new NeuralNetConfiguration.Builder().seed(555).list()
|
MultiLayerNetwork mln = new MultiLayerNetwork(NeuralNetConfiguration.builder().seed(555).list()
|
||||||
.layer(0, new OutputLayer.Builder().nOut(1).lossFunction(LossFunctions.LossFunction.XENT).activation(Activation.SIGMOID).build()).build());
|
.layer(0, new OutputLayer.Builder().nOut(1).lossFunction(LossFunctions.LossFunction.XENT).activation(Activation.SIGMOID).build()).build());
|
||||||
|
|
||||||
ACPolicy policy = new ACPolicy(new DummyAC(mln), true, Nd4j.getRandom());
|
ACPolicy policy = new ACPolicy(new DummyAC(mln), true, Nd4j.getRandom());
|
||||||
|
|
|
@ -48,12 +48,12 @@ Deeplearning4J offers a very high level API for defining even complex neural net
|
||||||
you how LeNet, a convolutional neural network, is defined in DL4J.
|
you how LeNet, a convolutional neural network, is defined in DL4J.
|
||||||
|
|
||||||
```java
|
```java
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.seed(seed)
|
.seed(seed)
|
||||||
.l2(0.0005)
|
.l2(0.0005)
|
||||||
.weightInit(WeightInit.XAVIER)
|
.weightInit(WeightInit.XAVIER)
|
||||||
.updater(new Adam(1e-3))
|
.updater(new Adam(1e-3))
|
||||||
.list()
|
|
||||||
.layer(new ConvolutionLayer.Builder(5, 5)
|
.layer(new ConvolutionLayer.Builder(5, 5)
|
||||||
.stride(1,1)
|
.stride(1,1)
|
||||||
.nOut(20)
|
.nOut(20)
|
||||||
|
@ -78,7 +78,7 @@ MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
||||||
.nOut(outputNum)
|
.nOut(outputNum)
|
||||||
.activation(Activation.SOFTMAX)
|
.activation(Activation.SOFTMAX)
|
||||||
.build())
|
.build())
|
||||||
.setInputType(InputType.convolutionalFlat(28,28,1))
|
.inputType(InputType.convolutionalFlat(28,28,1))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
|
@ -46,13 +46,12 @@ import org.datavec.image.transform.ResizeImageTransform;
|
||||||
import org.datavec.image.transform.ShowImageTransform;
|
import org.datavec.image.transform.ShowImageTransform;
|
||||||
import org.deeplearning4j.datasets.datavec.RecordReaderDataSetIterator;
|
import org.deeplearning4j.datasets.datavec.RecordReaderDataSetIterator;
|
||||||
import org.deeplearning4j.nn.conf.GradientNormalization;
|
import org.deeplearning4j.nn.conf.GradientNormalization;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.inputs.InputType;
|
import org.deeplearning4j.nn.conf.inputs.InputType;
|
||||||
import org.deeplearning4j.nn.conf.layers.ActivationLayer;
|
import org.deeplearning4j.nn.conf.layers.ActivationLayer;
|
||||||
import org.deeplearning4j.nn.conf.layers.DenseLayer;
|
import org.deeplearning4j.nn.conf.layers.DenseLayer;
|
||||||
import org.deeplearning4j.nn.conf.layers.DropoutLayer;
|
import org.deeplearning4j.nn.conf.layers.DropoutLayer;
|
||||||
import org.deeplearning4j.nn.conf.layers.Layer;
|
import org.deeplearning4j.nn.conf.layers.LayerConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.layers.OutputLayer;
|
import org.deeplearning4j.nn.conf.layers.OutputLayer;
|
||||||
import org.deeplearning4j.nn.conf.layers.misc.FrozenLayerWithBackprop;
|
import org.deeplearning4j.nn.conf.layers.misc.FrozenLayerWithBackprop;
|
||||||
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
||||||
|
@ -61,7 +60,6 @@ import org.deeplearning4j.nn.weights.WeightInitXavier;
|
||||||
import org.deeplearning4j.optimize.listeners.ScoreToChartListener;
|
import org.deeplearning4j.optimize.listeners.ScoreToChartListener;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.nd4j.linalg.activations.Activation;
|
import org.nd4j.linalg.activations.Activation;
|
||||||
import org.nd4j.linalg.activations.impl.ActivationIdentity;
|
|
||||||
import org.nd4j.linalg.activations.impl.ActivationLReLU;
|
import org.nd4j.linalg.activations.impl.ActivationLReLU;
|
||||||
import org.nd4j.linalg.api.ndarray.INDArray;
|
import org.nd4j.linalg.api.ndarray.INDArray;
|
||||||
import org.nd4j.linalg.dataset.DataSet;
|
import org.nd4j.linalg.dataset.DataSet;
|
||||||
|
@ -92,8 +90,8 @@ public class App {
|
||||||
private static JPanel panel;
|
private static JPanel panel;
|
||||||
private static JPanel panel2;
|
private static JPanel panel2;
|
||||||
|
|
||||||
private static Layer[] genLayers() {
|
private static LayerConfiguration[] genLayers() {
|
||||||
return new Layer[] {
|
return new LayerConfiguration[] {
|
||||||
new DenseLayer.Builder().nIn(INPUT).nOut(X_DIM*Y_DIM*CHANNELS).weightInit(WeightInit.NORMAL).build(),
|
new DenseLayer.Builder().nIn(INPUT).nOut(X_DIM*Y_DIM*CHANNELS).weightInit(WeightInit.NORMAL).build(),
|
||||||
new ActivationLayer.Builder(new ActivationLReLU(0.2)).build(),
|
new ActivationLayer.Builder(new ActivationLReLU(0.2)).build(),
|
||||||
new DenseLayer.Builder().nIn(X_DIM*Y_DIM*CHANNELS).nOut(X_DIM*Y_DIM).build(),
|
new DenseLayer.Builder().nIn(X_DIM*Y_DIM*CHANNELS).nOut(X_DIM*Y_DIM).build(),
|
||||||
|
@ -103,8 +101,6 @@ public class App {
|
||||||
new DenseLayer.Builder().nIn(X_DIM*Y_DIM).nOut(X_DIM*Y_DIM*CHANNELS).activation(Activation.TANH)
|
new DenseLayer.Builder().nIn(X_DIM*Y_DIM).nOut(X_DIM*Y_DIM*CHANNELS).activation(Activation.TANH)
|
||||||
.build()
|
.build()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -112,24 +108,26 @@ public class App {
|
||||||
*
|
*
|
||||||
* @return config
|
* @return config
|
||||||
*/
|
*/
|
||||||
private static MultiLayerConfiguration generator() {
|
private static NeuralNetConfiguration generator() {
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.seed(42)
|
.seed(42)
|
||||||
.updater(UPDATER)
|
.updater(UPDATER)
|
||||||
.gradientNormalization(GradientNormalization.RenormalizeL2PerLayer)
|
.gradientNormalization(GradientNormalization.RenormalizeL2PerLayer)
|
||||||
.gradientNormalizationThreshold(GRADIENT_THRESHOLD)
|
.gradientNormalizationThreshold(GRADIENT_THRESHOLD)
|
||||||
.weightInit(WeightInit.XAVIER)
|
//.weightInit(WeightInit.XAVIER)
|
||||||
|
.weightInitFn(new WeightInitXavier())
|
||||||
.activation(Activation.IDENTITY)
|
.activation(Activation.IDENTITY)
|
||||||
.list(genLayers())
|
.layersFromArray(genLayers())
|
||||||
.setInputType(InputType.convolutional(X_DIM, Y_DIM, CHANNELS))
|
.inputType(InputType.convolutional(X_DIM, Y_DIM, CHANNELS))
|
||||||
// .inputPreProcessor("CNN1", new FeedForwardToCnnPreProcessor(Y_DIM, X_DIM, CHANNELS))
|
// .inputPreProcessor("CNN1", new FeedForwardToCnnPreProcessor(Y_DIM, X_DIM, CHANNELS))
|
||||||
.build();
|
.build();
|
||||||
|
((NeuralNetConfiguration) conf).init();
|
||||||
|
|
||||||
return conf;
|
return conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Layer[] disLayers() {
|
private static LayerConfiguration[] disLayers() {
|
||||||
return new Layer[]{
|
return new LayerConfiguration[]{
|
||||||
new DenseLayer.Builder().nOut(X_DIM*Y_DIM*CHANNELS*2).build(), //input is set by setInputType on the network
|
new DenseLayer.Builder().nOut(X_DIM*Y_DIM*CHANNELS*2).build(), //input is set by setInputType on the network
|
||||||
new ActivationLayer.Builder(new ActivationLReLU(0.2)).build(),
|
new ActivationLayer.Builder(new ActivationLReLU(0.2)).build(),
|
||||||
new DropoutLayer.Builder(1 - 0.5).build(),
|
new DropoutLayer.Builder(1 - 0.5).build(),
|
||||||
|
@ -146,45 +144,50 @@ public class App {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private static MultiLayerConfiguration discriminator() {
|
private static NeuralNetConfiguration discriminator() {
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.seed(42)
|
.seed(42)
|
||||||
.updater(UPDATER)
|
.updater(UPDATER)
|
||||||
.gradientNormalization(GradientNormalization.RenormalizeL2PerLayer)
|
.gradientNormalization(GradientNormalization.RenormalizeL2PerLayer)
|
||||||
.gradientNormalizationThreshold(GRADIENT_THRESHOLD)
|
.gradientNormalizationThreshold(GRADIENT_THRESHOLD)
|
||||||
.weightInit(WeightInit.XAVIER)
|
.weightInit(WeightInit.XAVIER)
|
||||||
|
//.weightInitFn(new WeightInitXavier())
|
||||||
|
//.activationFn(new ActivationIdentity())
|
||||||
.activation(Activation.IDENTITY)
|
.activation(Activation.IDENTITY)
|
||||||
.list(disLayers())
|
.layersFromArray(disLayers())
|
||||||
.setInputType(InputType.convolutional(X_DIM, Y_DIM, CHANNELS))
|
.inputType(InputType.convolutional(X_DIM, Y_DIM, CHANNELS))
|
||||||
.build();
|
.build();
|
||||||
|
((NeuralNetConfiguration) conf).init();
|
||||||
|
|
||||||
return conf;
|
return conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static MultiLayerConfiguration gan() {
|
private static NeuralNetConfiguration gan() {
|
||||||
Layer[] genLayers = genLayers();
|
LayerConfiguration[] genLayers = genLayers();
|
||||||
Layer[] disLayers = Arrays.stream(disLayers())
|
LayerConfiguration[] disLayers = Arrays.stream(disLayers())
|
||||||
.map((layer) -> {
|
.map((layer) -> {
|
||||||
if (layer instanceof DenseLayer || layer instanceof OutputLayer) {
|
if (layer instanceof DenseLayer || layer instanceof OutputLayer) {
|
||||||
return new FrozenLayerWithBackprop(layer);
|
return new FrozenLayerWithBackprop(layer);
|
||||||
} else {
|
} else {
|
||||||
return layer;
|
return layer;
|
||||||
}
|
}
|
||||||
}).toArray(Layer[]::new);
|
}).toArray(LayerConfiguration[]::new);
|
||||||
Layer[] layers = ArrayUtils.addAll(genLayers, disLayers);
|
LayerConfiguration[] layers = ArrayUtils.addAll(genLayers, disLayers);
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.seed(42)
|
.seed(42)
|
||||||
.updater( Adam.builder().learningRate(0.0002).beta1(0.5).build() )
|
.updater( Adam.builder().learningRate(0.0002).beta1(0.5).build() )
|
||||||
.gradientNormalization( GradientNormalization.RenormalizeL2PerLayer)
|
.gradientNormalization( GradientNormalization.RenormalizeL2PerLayer)
|
||||||
.gradientNormalizationThreshold( 100 )
|
.gradientNormalizationThreshold( 100 )
|
||||||
.weightInit( new WeightInitXavier() )
|
//.weightInitFn( new WeightInitXavier() ) //this is internal
|
||||||
.activation( new ActivationIdentity())
|
.weightInit( WeightInit.XAVIER)
|
||||||
.list( layers )
|
//.activationFn( new ActivationIdentity()) //this is internal
|
||||||
.setInputType( InputType.convolutional(X_DIM, Y_DIM, CHANNELS))
|
.activation( Activation.IDENTITY )
|
||||||
|
.layersFromArray( layers )
|
||||||
|
.inputType( InputType.convolutional(X_DIM, Y_DIM, CHANNELS))
|
||||||
.build();
|
.build();
|
||||||
|
((NeuralNetConfiguration) conf).init();
|
||||||
return conf;
|
return conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,6 +198,8 @@ public class App {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String... args) throws Exception {
|
public static void main(String... args) throws Exception {
|
||||||
|
|
||||||
|
log.info("\u001B[32m Some \u001B[1m green \u001B[22m text \u001B[0m \u001B[7m Inverted\u001B[0m ");
|
||||||
Nd4j.getMemoryManager().setAutoGcWindow(15 * 1000);
|
Nd4j.getMemoryManager().setAutoGcWindow(15 * 1000);
|
||||||
|
|
||||||
// MnistDataSetIterator trainData = new MnistDataSetIterator(128, true, 45);
|
// MnistDataSetIterator trainData = new MnistDataSetIterator(128, true, 45);
|
||||||
|
@ -220,9 +225,10 @@ public class App {
|
||||||
MultiLayerNetwork gen = new MultiLayerNetwork(generator());
|
MultiLayerNetwork gen = new MultiLayerNetwork(generator());
|
||||||
MultiLayerNetwork dis = new MultiLayerNetwork(discriminator());
|
MultiLayerNetwork dis = new MultiLayerNetwork(discriminator());
|
||||||
MultiLayerNetwork gan = new MultiLayerNetwork(gan());
|
MultiLayerNetwork gan = new MultiLayerNetwork(gan());
|
||||||
gen.init();
|
gen.init(); log.debug("Generator network: {}", gen);
|
||||||
dis.init();
|
dis.init(); log.debug("Discriminator network: {}", dis);
|
||||||
gan.init();
|
gan.init(); log.debug("Complete GAN network: {}", gan);
|
||||||
|
|
||||||
|
|
||||||
copyParams(gen, dis, gan);
|
copyParams(gen, dis, gan);
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.deeplearning4j.nn.api.Layer;
|
import org.deeplearning4j.nn.api.Layer;
|
||||||
import org.deeplearning4j.nn.api.OptimizationAlgorithm;
|
import org.deeplearning4j.nn.api.OptimizationAlgorithm;
|
||||||
import org.deeplearning4j.nn.conf.*;
|
import org.deeplearning4j.nn.conf.*;
|
||||||
|
import org.deeplearning4j.nn.conf.layers.LayerConfiguration;
|
||||||
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
||||||
import org.deeplearning4j.optimize.api.BaseTrainingListener;
|
import org.deeplearning4j.optimize.api.BaseTrainingListener;
|
||||||
import org.nd4j.evaluation.classification.Evaluation;
|
import org.nd4j.evaluation.classification.Evaluation;
|
||||||
|
@ -199,13 +200,13 @@ public class GAN {
|
||||||
|
|
||||||
Layer[] disLayers = ganDiscriminator.getLayers();
|
Layer[] disLayers = ganDiscriminator.getLayers();
|
||||||
Layer[] layers = ArrayUtils.addAll(genLayers, disLayers);
|
Layer[] layers = ArrayUtils.addAll(genLayers, disLayers);
|
||||||
MultiLayerConfiguration genConf = generator.getLayerWiseConfigurations();
|
NeuralNetConfiguration genConf = generator.getConfiguration();
|
||||||
MultiLayerConfiguration disConf = ganDiscriminator.getLayerWiseConfigurations();
|
NeuralNetConfiguration disConf = ganDiscriminator.getConfiguration();
|
||||||
org.deeplearning4j.nn.conf.layers.Layer[] confLayers = new org.deeplearning4j.nn.conf.layers.Layer[layers.length];
|
LayerConfiguration[] confLayers = new LayerConfiguration[layers.length];
|
||||||
|
|
||||||
Map<Integer, InputPreProcessor> preProcessors = new HashMap<>();
|
Map<Integer, InputPreProcessor> preProcessors = new HashMap<>();
|
||||||
for (int i = 0; i < layers.length; i++) {
|
for (int i = 0; i < layers.length; i++) {
|
||||||
confLayers[i] = layers[i].conf().getLayer();
|
confLayers[i] = layers[i].getLayerConfiguration();
|
||||||
if (i < numGenLayers) {
|
if (i < numGenLayers) {
|
||||||
preProcessors.put(i, genConf.getInputPreProcess(i));
|
preProcessors.put(i, genConf.getInputPreProcess(i));
|
||||||
} else {
|
} else {
|
||||||
|
@ -213,7 +214,7 @@ public class GAN {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiLayerConfiguration ganConf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration ganConf = NeuralNetConfiguration.builder()
|
||||||
.seed(seed)
|
.seed(seed)
|
||||||
.updater(updater)
|
.updater(updater)
|
||||||
.biasUpdater(biasUpdater)
|
.biasUpdater(biasUpdater)
|
||||||
|
@ -224,7 +225,7 @@ public class GAN {
|
||||||
.trainingWorkspaceMode(trainingWorkSpaceMode)
|
.trainingWorkspaceMode(trainingWorkSpaceMode)
|
||||||
.inferenceWorkspaceMode(inferenceWorkspaceMode)
|
.inferenceWorkspaceMode(inferenceWorkspaceMode)
|
||||||
.cacheMode(cacheMode)
|
.cacheMode(cacheMode)
|
||||||
.list(confLayers)
|
.layersFromArray(confLayers)
|
||||||
.inputPreProcessors(preProcessors)
|
.inputPreProcessors(preProcessors)
|
||||||
.build();
|
.build();
|
||||||
gan = new MultiLayerNetwork(ganConf);
|
gan = new MultiLayerNetwork(ganConf);
|
||||||
|
@ -267,7 +268,7 @@ public class GAN {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GAN builder, used as a starting point for creating a MultiLayerConfiguration or
|
* GAN builder, used as a starting point for creating a NeuralNetConfiguration or
|
||||||
* ComputationGraphConfiguration.<br>
|
* ComputationGraphConfiguration.<br>
|
||||||
*/
|
*/
|
||||||
public static class Builder implements Cloneable {
|
public static class Builder implements Cloneable {
|
||||||
|
|
|
@ -100,7 +100,7 @@ public class MnistDCGANExample {
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
Supplier<MultiLayerNetwork> genSupplier = () -> {
|
Supplier<MultiLayerNetwork> genSupplier = () -> {
|
||||||
return new MultiLayerNetwork(new NeuralNetConfiguration.Builder().list()
|
return new MultiLayerNetwork(NeuralNetConfiguration.builder()
|
||||||
.layer(0, new DenseLayer.Builder().nIn(latentDim).nOut(width / 2 * height / 2 * 128)
|
.layer(0, new DenseLayer.Builder().nIn(latentDim).nOut(width / 2 * height / 2 * 128)
|
||||||
.activation(Activation.LEAKYRELU).weightInit(WeightInit.NORMAL).build())
|
.activation(Activation.LEAKYRELU).weightInit(WeightInit.NORMAL).build())
|
||||||
.layer(1, new Convolution2D.Builder().nIn(128).nOut(128).kernelSize(5, 5)
|
.layer(1, new Convolution2D.Builder().nIn(128).nOut(128).kernelSize(5, 5)
|
||||||
|
@ -119,16 +119,16 @@ public class MnistDCGANExample {
|
||||||
.inputPreProcessor(1,
|
.inputPreProcessor(1,
|
||||||
new FeedForwardToCnnPreProcessor(height / 2, width / 2, 128))
|
new FeedForwardToCnnPreProcessor(height / 2, width / 2, 128))
|
||||||
.inputPreProcessor(6, new CnnToFeedForwardPreProcessor(height, width, channels))
|
.inputPreProcessor(6, new CnnToFeedForwardPreProcessor(height, width, channels))
|
||||||
.setInputType(InputType.feedForward(latentDim))
|
.inputType(InputType.feedForward(latentDim))
|
||||||
.build());
|
.build());
|
||||||
};
|
};
|
||||||
|
|
||||||
GAN.DiscriminatorProvider discriminatorProvider = (updater) -> {
|
GAN.DiscriminatorProvider discriminatorProvider = (updater) -> {
|
||||||
return new MultiLayerNetwork(new NeuralNetConfiguration.Builder()
|
return new MultiLayerNetwork(NeuralNetConfiguration.builder()
|
||||||
.updater(new RmsProp.Builder().learningRate(0.0008).rmsDecay(1e-8).build())
|
.updater(new RmsProp.Builder().learningRate(0.0008).rmsDecay(1e-8).build())
|
||||||
//.gradientNormalization(GradientNormalization.ClipElementWiseAbsoluteValue)
|
//.gradientNormalization(GradientNormalization.ClipElementWiseAbsoluteValue)
|
||||||
//.gradientNormalizationThreshold(100.0)
|
//.gradientNormalizationThreshold(100.0)
|
||||||
.list()
|
|
||||||
.layer(0, new Convolution2D.Builder().nIn(channels).nOut(64).kernelSize(3, 3)
|
.layer(0, new Convolution2D.Builder().nIn(channels).nOut(64).kernelSize(3, 3)
|
||||||
.activation(Activation.LEAKYRELU).build())
|
.activation(Activation.LEAKYRELU).build())
|
||||||
.layer(1, new Convolution2D.Builder().nIn(64).nOut(64).kernelSize(3, 3).stride(2, 2)
|
.layer(1, new Convolution2D.Builder().nIn(64).nOut(64).kernelSize(3, 3).stride(2, 2)
|
||||||
|
@ -142,7 +142,7 @@ public class MnistDCGANExample {
|
||||||
.layer(6, new LossLayer.Builder().lossFunction(LossFunctions.LossFunction.XENT).build())
|
.layer(6, new LossLayer.Builder().lossFunction(LossFunctions.LossFunction.XENT).build())
|
||||||
.inputPreProcessor(0, new FeedForwardToCnnPreProcessor(height, width, channels))
|
.inputPreProcessor(0, new FeedForwardToCnnPreProcessor(height, width, channels))
|
||||||
.inputPreProcessor(4, new CnnToFeedForwardPreProcessor(2, 2, 64))
|
.inputPreProcessor(4, new CnnToFeedForwardPreProcessor(2, 2, 64))
|
||||||
.setInputType(InputType.convolutionalFlat(height, width, channels))
|
.inputType(InputType.convolutionalFlat(height, width, channels))
|
||||||
.build());
|
.build());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@ package net.brutex.gan;
|
||||||
|
|
||||||
import org.deeplearning4j.datasets.iterator.impl.MnistDataSetIterator;
|
import org.deeplearning4j.datasets.iterator.impl.MnistDataSetIterator;
|
||||||
import org.deeplearning4j.nn.conf.GradientNormalization;
|
import org.deeplearning4j.nn.conf.GradientNormalization;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.layers.ActivationLayer;
|
import org.deeplearning4j.nn.conf.layers.ActivationLayer;
|
||||||
import org.deeplearning4j.nn.conf.layers.DenseLayer;
|
import org.deeplearning4j.nn.conf.layers.DenseLayer;
|
||||||
|
@ -57,12 +56,12 @@ public class MnistSimpleGAN {
|
||||||
|
|
||||||
|
|
||||||
public static MultiLayerNetwork getGenerator() {
|
public static MultiLayerNetwork getGenerator() {
|
||||||
MultiLayerConfiguration genConf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration genConf = NeuralNetConfiguration.builder()
|
||||||
.weightInit(WeightInit.XAVIER)
|
.weightInit(WeightInit.XAVIER)
|
||||||
.activation(Activation.IDENTITY)
|
.activation(Activation.IDENTITY)
|
||||||
.gradientNormalization(GradientNormalization.RenormalizeL2PerLayer)
|
.gradientNormalization(GradientNormalization.RenormalizeL2PerLayer)
|
||||||
.gradientNormalizationThreshold(100)
|
.gradientNormalizationThreshold(100)
|
||||||
.list()
|
|
||||||
.layer(new DenseLayer.Builder().nIn(100).nOut(256).weightInit(WeightInit.NORMAL).build())
|
.layer(new DenseLayer.Builder().nIn(100).nOut(256).weightInit(WeightInit.NORMAL).build())
|
||||||
.layer(new ActivationLayer.Builder(new ActivationLReLU(0.2)).build())
|
.layer(new ActivationLayer.Builder(new ActivationLReLU(0.2)).build())
|
||||||
.layer(new DenseLayer.Builder().nIn(256).nOut(512).build())
|
.layer(new DenseLayer.Builder().nIn(256).nOut(512).build())
|
||||||
|
@ -76,14 +75,14 @@ public class MnistSimpleGAN {
|
||||||
|
|
||||||
|
|
||||||
public static MultiLayerNetwork getDiscriminator(IUpdater updater) {
|
public static MultiLayerNetwork getDiscriminator(IUpdater updater) {
|
||||||
MultiLayerConfiguration discConf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration discConf = NeuralNetConfiguration.builder()
|
||||||
.seed(42)
|
.seed(42)
|
||||||
.updater(updater)
|
.updater(updater)
|
||||||
.weightInit(WeightInit.XAVIER)
|
.weightInit(WeightInit.XAVIER)
|
||||||
.activation(Activation.IDENTITY)
|
.activation(Activation.IDENTITY)
|
||||||
.gradientNormalization(GradientNormalization.RenormalizeL2PerLayer)
|
.gradientNormalization(GradientNormalization.RenormalizeL2PerLayer)
|
||||||
.gradientNormalizationThreshold(100)
|
.gradientNormalizationThreshold(100)
|
||||||
.list()
|
|
||||||
.layer(new DenseLayer.Builder().nIn(784).nOut(1024).updater(updater).build())
|
.layer(new DenseLayer.Builder().nIn(784).nOut(1024).updater(updater).build())
|
||||||
.layer(new ActivationLayer.Builder(new ActivationLReLU(0.2)).build())
|
.layer(new ActivationLayer.Builder(new ActivationLReLU(0.2)).build())
|
||||||
.layer(new DropoutLayer.Builder(1 - 0.5).build())
|
.layer(new DropoutLayer.Builder(1 - 0.5).build())
|
||||||
|
|
|
@ -35,7 +35,6 @@ import org.apache.spark.sql.RowFactory;
|
||||||
import org.apache.spark.sql.SparkSession;
|
import org.apache.spark.sql.SparkSession;
|
||||||
import org.apache.spark.sql.types.DataTypes;
|
import org.apache.spark.sql.types.DataTypes;
|
||||||
import org.apache.spark.sql.types.Metadata;
|
import org.apache.spark.sql.types.Metadata;
|
||||||
import org.apache.spark.sql.types.StringType;
|
|
||||||
import org.apache.spark.sql.types.StructField;
|
import org.apache.spark.sql.types.StructField;
|
||||||
import org.apache.spark.sql.types.StructType;
|
import org.apache.spark.sql.types.StructType;
|
||||||
import org.datavec.api.records.reader.impl.csv.CSVRecordReader;
|
import org.datavec.api.records.reader.impl.csv.CSVRecordReader;
|
||||||
|
@ -43,12 +42,10 @@ import org.datavec.api.transform.TransformProcess;
|
||||||
import org.datavec.api.transform.filter.FilterInvalidValues;
|
import org.datavec.api.transform.filter.FilterInvalidValues;
|
||||||
import org.datavec.api.transform.schema.Schema;
|
import org.datavec.api.transform.schema.Schema;
|
||||||
import org.datavec.api.Writable;
|
import org.datavec.api.Writable;
|
||||||
import org.datavec.spark.transform.Normalization;
|
|
||||||
import org.datavec.spark.transform.SparkTransformExecutor;
|
import org.datavec.spark.transform.SparkTransformExecutor;
|
||||||
import org.datavec.spark.transform.misc.StringToWritablesFunction;
|
import org.datavec.spark.transform.misc.StringToWritablesFunction;
|
||||||
import org.deeplearning4j.datasets.iterator.impl.EmnistDataSetIterator;
|
import org.deeplearning4j.datasets.iterator.impl.EmnistDataSetIterator;
|
||||||
import org.deeplearning4j.datasets.iterator.impl.EmnistDataSetIterator.Set;
|
import org.deeplearning4j.datasets.iterator.impl.EmnistDataSetIterator.Set;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.layers.DenseLayer;
|
import org.deeplearning4j.nn.conf.layers.DenseLayer;
|
||||||
import org.deeplearning4j.nn.conf.layers.OutputLayer;
|
import org.deeplearning4j.nn.conf.layers.OutputLayer;
|
||||||
|
@ -287,10 +284,10 @@ public class BrianTest extends BaseSparkSessionTest {
|
||||||
|
|
||||||
//Define Network
|
//Define Network
|
||||||
|
|
||||||
MultiLayerConfiguration multiLayerConfiguration = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration multiLayerConfiguration = NeuralNetConfiguration.builder()
|
||||||
.seed(123)
|
.seed(123)
|
||||||
.updater(new Nesterovs(0.1, 0.9))
|
.updater(new Nesterovs(0.1, 0.9))
|
||||||
.list()
|
|
||||||
.layer(0, new DenseLayer.Builder().nIn(5).nOut(20).weightInit(WeightInit.XAVIER)
|
.layer(0, new DenseLayer.Builder().nIn(5).nOut(20).weightInit(WeightInit.XAVIER)
|
||||||
.activation(Activation.RELU).l2(0.001).build())
|
.activation(Activation.RELU).l2(0.001).build())
|
||||||
.layer(1, new DenseLayer.Builder().nIn(20).nOut(20).weightInit(WeightInit.XAVIER)
|
.layer(1, new DenseLayer.Builder().nIn(20).nOut(20).weightInit(WeightInit.XAVIER)
|
||||||
|
|
|
@ -37,7 +37,6 @@ import org.datavec.api.transform.schema.Schema;
|
||||||
import org.datavec.api.Writable;
|
import org.datavec.api.Writable;
|
||||||
import org.datavec.spark.transform.SparkTransformExecutor;
|
import org.datavec.spark.transform.SparkTransformExecutor;
|
||||||
import org.datavec.spark.transform.misc.StringToWritablesFunction;
|
import org.datavec.spark.transform.misc.StringToWritablesFunction;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.layers.DenseLayer;
|
import org.deeplearning4j.nn.conf.layers.DenseLayer;
|
||||||
import org.deeplearning4j.nn.conf.layers.OutputLayer;
|
import org.deeplearning4j.nn.conf.layers.OutputLayer;
|
||||||
|
@ -295,10 +294,10 @@ public class BrianTest2 /*extends BaseDL4JTest*/ {
|
||||||
*/
|
*/
|
||||||
//Define Network
|
//Define Network
|
||||||
|
|
||||||
MultiLayerConfiguration multiLayerConfiguration = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration multiLayerConfiguration = NeuralNetConfiguration.builder()
|
||||||
.seed(123)
|
.seed(123)
|
||||||
.updater(new Nesterovs(0.1, 0.9))
|
.updater(new Nesterovs(0.1, 0.9))
|
||||||
.list()
|
|
||||||
.layer(0, new DenseLayer.Builder().nIn(5).nOut(20).weightInit(WeightInit.XAVIER).activation(Activation.RELU).l2(0.001).build())
|
.layer(0, new DenseLayer.Builder().nIn(5).nOut(20).weightInit(WeightInit.XAVIER).activation(Activation.RELU).l2(0.001).build())
|
||||||
.layer(1, new DenseLayer.Builder().nIn(20).nOut(20).weightInit(WeightInit.XAVIER).activation(Activation.RELU).build())
|
.layer(1, new DenseLayer.Builder().nIn(20).nOut(20).weightInit(WeightInit.XAVIER).activation(Activation.RELU).build())
|
||||||
//.layer(2, new DenseLayerConfiguration.Builder().nIn(9).nOut(9).weightInit(WeightInit.XAVIER).activation(Activation.RELU).build())
|
//.layer(2, new DenseLayerConfiguration.Builder().nIn(9).nOut(9).weightInit(WeightInit.XAVIER).activation(Activation.RELU).build())
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
|
|
||||||
package net.brutex.spark;
|
package net.brutex.spark;
|
||||||
|
|
||||||
import lombok.extern.log4j.Log4j2;
|
|
||||||
//import net.brutex.ai.performance.storage.PostgresStatsStorage;
|
//import net.brutex.ai.performance.storage.PostgresStatsStorage;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.datavec.api.records.reader.RecordReader;
|
import org.datavec.api.records.reader.RecordReader;
|
||||||
|
@ -29,9 +28,7 @@ import org.datavec.api.records.reader.impl.collection.ListStringRecordReader;
|
||||||
import org.datavec.api.records.reader.impl.csv.CSVRecordReader;
|
import org.datavec.api.records.reader.impl.csv.CSVRecordReader;
|
||||||
import org.datavec.api.split.FileSplit;
|
import org.datavec.api.split.FileSplit;
|
||||||
import org.datavec.api.split.ListStringSplit;
|
import org.datavec.api.split.ListStringSplit;
|
||||||
import org.deeplearning4j.core.storage.StatsStorage;
|
|
||||||
import org.deeplearning4j.datasets.datavec.RecordReaderDataSetIterator;
|
import org.deeplearning4j.datasets.datavec.RecordReaderDataSetIterator;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.layers.DenseLayer;
|
import org.deeplearning4j.nn.conf.layers.DenseLayer;
|
||||||
import org.deeplearning4j.nn.conf.layers.LSTM;
|
import org.deeplearning4j.nn.conf.layers.LSTM;
|
||||||
|
@ -40,10 +37,7 @@ import org.deeplearning4j.nn.conf.preprocessor.FeedForwardToRnnPreProcessor;
|
||||||
import org.deeplearning4j.nn.conf.preprocessor.RnnToFeedForwardPreProcessor;
|
import org.deeplearning4j.nn.conf.preprocessor.RnnToFeedForwardPreProcessor;
|
||||||
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
||||||
import org.deeplearning4j.nn.weights.WeightInit;
|
import org.deeplearning4j.nn.weights.WeightInit;
|
||||||
import org.deeplearning4j.optimize.listeners.ScoreIterationListener;
|
|
||||||
import org.deeplearning4j.ui.api.UIServer;
|
import org.deeplearning4j.ui.api.UIServer;
|
||||||
import org.deeplearning4j.ui.model.stats.StatsListener;
|
|
||||||
import org.deeplearning4j.ui.model.storage.FileStatsStorage;
|
|
||||||
import org.junit.jupiter.api.AfterAll;
|
import org.junit.jupiter.api.AfterAll;
|
||||||
import org.junit.jupiter.api.Tag;
|
import org.junit.jupiter.api.Tag;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
@ -86,13 +80,13 @@ public class TestServer {
|
||||||
int i = 2000;
|
int i = 2000;
|
||||||
int numClasses = 10;
|
int numClasses = 10;
|
||||||
int numBatchSize = 100;
|
int numBatchSize = 100;
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.seed(1234)
|
.seed(1234)
|
||||||
.weightInit(WeightInit.XAVIER)
|
.weightInit(WeightInit.XAVIER)
|
||||||
.updater(new Nesterovs.Builder().learningRate(0.15).build())
|
.updater(new Nesterovs.Builder().learningRate(0.15).build())
|
||||||
.activation(Activation.RELU)
|
.activation(Activation.RELU)
|
||||||
.l2(0)
|
.l2(0)
|
||||||
.list()
|
|
||||||
//.layer(0, new ConvolutionLayer.Builder().nIn(1).kernelSize(1, 5).stride(1,1).padding(0,2).nOut(1).name("1st Filter").updater(new Adam.Builder().learningRate(0.2).build()).build())
|
//.layer(0, new ConvolutionLayer.Builder().nIn(1).kernelSize(1, 5).stride(1,1).padding(0,2).nOut(1).name("1st Filter").updater(new Adam.Builder().learningRate(0.2).build()).build())
|
||||||
//.layer(1, new ConvolutionLayer.Builder().nIn(1).kernelSize(1, 2).stride(1,2).padding(0,0).nOut(1).name("2nd Filter").updater(new Adam.Builder().learningRate(0.1).build()).build())
|
//.layer(1, new ConvolutionLayer.Builder().nIn(1).kernelSize(1, 2).stride(1,2).padding(0,0).nOut(1).name("2nd Filter").updater(new Adam.Builder().learningRate(0.1).build()).build())
|
||||||
// .layer(1, new DenseLayerConfiguration.Builder().nIn(10).nOut(64).activation(Activation.RELU).build())
|
// .layer(1, new DenseLayerConfiguration.Builder().nIn(10).nOut(64).activation(Activation.RELU).build())
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
|
|
||||||
package net.brutex.spark;
|
package net.brutex.spark;
|
||||||
|
|
||||||
import lombok.extern.log4j.Log4j2;
|
|
||||||
//import net.brutex.ai.performance.storage.PostgresStatsStorage;
|
//import net.brutex.ai.performance.storage.PostgresStatsStorage;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.datavec.api.records.reader.RecordReader;
|
import org.datavec.api.records.reader.RecordReader;
|
||||||
|
@ -32,7 +31,6 @@ import org.datavec.api.split.ListStringSplit;
|
||||||
import org.datavec.image.recordreader.ImageRecordReader;
|
import org.datavec.image.recordreader.ImageRecordReader;
|
||||||
import org.deeplearning4j.core.storage.StatsStorage;
|
import org.deeplearning4j.core.storage.StatsStorage;
|
||||||
import org.deeplearning4j.datasets.datavec.RecordReaderDataSetIterator;
|
import org.deeplearning4j.datasets.datavec.RecordReaderDataSetIterator;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.layers.DenseLayer;
|
import org.deeplearning4j.nn.conf.layers.DenseLayer;
|
||||||
import org.deeplearning4j.nn.conf.layers.LSTM;
|
import org.deeplearning4j.nn.conf.layers.LSTM;
|
||||||
|
@ -122,13 +120,13 @@ public class TestServer2 {
|
||||||
int i = 2000;
|
int i = 2000;
|
||||||
int numClasses = 10;
|
int numClasses = 10;
|
||||||
int numBatchSize = 100;
|
int numBatchSize = 100;
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.seed(1234)
|
.seed(1234)
|
||||||
.weightInit(WeightInit.XAVIER)
|
.weightInit(WeightInit.XAVIER)
|
||||||
.updater(new Nesterovs.Builder().learningRate(0.15).build())
|
.updater(new Nesterovs.Builder().learningRate(0.15).build())
|
||||||
.activation(Activation.RELU)
|
.activation(Activation.RELU)
|
||||||
.l2(0)
|
.l2(0)
|
||||||
.list()
|
|
||||||
//.layer(0, new ConvolutionLayer.Builder().nIn(1).kernelSize(1, 5).stride(1,1).padding(0,2).nOut(1).name("1st Filter").updater(new Adam.Builder().learningRate(0.2).build()).build())
|
//.layer(0, new ConvolutionLayer.Builder().nIn(1).kernelSize(1, 5).stride(1,1).padding(0,2).nOut(1).name("1st Filter").updater(new Adam.Builder().learningRate(0.2).build()).build())
|
||||||
//.layer(1, new ConvolutionLayer.Builder().nIn(1).kernelSize(1, 2).stride(1,2).padding(0,0).nOut(1).name("2nd Filter").updater(new Adam.Builder().learningRate(0.1).build()).build())
|
//.layer(1, new ConvolutionLayer.Builder().nIn(1).kernelSize(1, 2).stride(1,2).padding(0,0).nOut(1).name("2nd Filter").updater(new Adam.Builder().learningRate(0.1).build()).build())
|
||||||
// .layer(1, new DenseLayerConfiguration.Builder().nIn(10).nOut(64).activation(Activation.RELU).build())
|
// .layer(1, new DenseLayerConfiguration.Builder().nIn(10).nOut(64).activation(Activation.RELU).build())
|
||||||
|
|
|
@ -21,14 +21,14 @@
|
||||||
package org.deeplearning4j.integration;
|
package org.deeplearning4j.integration;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.brutex.ai.dnn.api.IModel;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.deeplearning4j.datasets.iterator.MultiDataSetWrapperIterator;
|
import org.deeplearning4j.datasets.iterator.MultiDataSetWrapperIterator;
|
||||||
import org.deeplearning4j.integration.testcases.samediff.SameDiffCNNCases;
|
import org.deeplearning4j.integration.testcases.samediff.SameDiffCNNCases;
|
||||||
import org.deeplearning4j.integration.testcases.samediff.SameDiffMLPTestCases;
|
import org.deeplearning4j.integration.testcases.samediff.SameDiffMLPTestCases;
|
||||||
import org.deeplearning4j.integration.testcases.samediff.SameDiffRNNTestCases;
|
import org.deeplearning4j.integration.testcases.samediff.SameDiffRNNTestCases;
|
||||||
import org.deeplearning4j.nn.api.Model;
|
|
||||||
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.graph.ComputationGraph;
|
import org.deeplearning4j.nn.graph.ComputationGraph;
|
||||||
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
||||||
import org.deeplearning4j.optimize.listeners.CollectScoresListener;
|
import org.deeplearning4j.optimize.listeners.CollectScoresListener;
|
||||||
|
@ -135,12 +135,12 @@ public class IntegrationTestBaselineGenerator {
|
||||||
MultiLayerNetwork mln = null;
|
MultiLayerNetwork mln = null;
|
||||||
ComputationGraph cg = null;
|
ComputationGraph cg = null;
|
||||||
SameDiff sd = null;
|
SameDiff sd = null;
|
||||||
Model m = null;
|
IModel m = null;
|
||||||
if (tc.getTestType() == TestCase.TestType.RANDOM_INIT) {
|
if (tc.getTestType() == TestCase.TestType.RANDOM_INIT) {
|
||||||
Object config = tc.getConfiguration();
|
Object config = tc.getConfiguration();
|
||||||
String json = null;
|
String json = null;
|
||||||
if (config instanceof MultiLayerConfiguration) {
|
if (config instanceof NeuralNetConfiguration) {
|
||||||
MultiLayerConfiguration mlc = (MultiLayerConfiguration) config;
|
NeuralNetConfiguration mlc = (NeuralNetConfiguration) config;
|
||||||
json = mlc.toJson();
|
json = mlc.toJson();
|
||||||
mln = new MultiLayerNetwork(mlc);
|
mln = new MultiLayerNetwork(mlc);
|
||||||
mln.init();
|
mln.init();
|
||||||
|
|
|
@ -25,18 +25,18 @@ import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.reflect.ClassPath;
|
import com.google.common.reflect.ClassPath;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.brutex.ai.dnn.api.IModel;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.deeplearning4j.BaseDL4JTest;
|
import org.deeplearning4j.BaseDL4JTest;
|
||||||
import org.deeplearning4j.common.config.DL4JClassLoading;
|
import org.deeplearning4j.common.config.DL4JClassLoading;
|
||||||
import org.deeplearning4j.datasets.iterator.MultiDataSetWrapperIterator;
|
import org.deeplearning4j.datasets.iterator.MultiDataSetWrapperIterator;
|
||||||
import org.deeplearning4j.integration.util.CountingMultiDataSetIterator;
|
import org.deeplearning4j.integration.util.CountingMultiDataSetIterator;
|
||||||
import org.deeplearning4j.nn.api.Model;
|
|
||||||
import org.deeplearning4j.nn.conf.BackpropType;
|
import org.deeplearning4j.nn.conf.BackpropType;
|
||||||
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.InputPreProcessor;
|
import org.deeplearning4j.nn.conf.InputPreProcessor;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.graph.LayerVertex;
|
import org.deeplearning4j.nn.conf.graph.LayerVertex;
|
||||||
import org.deeplearning4j.nn.conf.layers.Layer;
|
import org.deeplearning4j.nn.conf.layers.LayerConfiguration;
|
||||||
import org.deeplearning4j.nn.graph.ComputationGraph;
|
import org.deeplearning4j.nn.graph.ComputationGraph;
|
||||||
import org.deeplearning4j.nn.graph.vertex.GraphVertex;
|
import org.deeplearning4j.nn.graph.vertex.GraphVertex;
|
||||||
import org.deeplearning4j.nn.layers.BaseOutputLayer;
|
import org.deeplearning4j.nn.layers.BaseOutputLayer;
|
||||||
|
@ -177,22 +177,22 @@ public class IntegrationTestRunner {
|
||||||
MultiLayerNetwork mln = null;
|
MultiLayerNetwork mln = null;
|
||||||
ComputationGraph cg = null;
|
ComputationGraph cg = null;
|
||||||
SameDiff sd = null;
|
SameDiff sd = null;
|
||||||
Model m = null;
|
IModel m = null;
|
||||||
if (tc.getTestType() == TestCase.TestType.RANDOM_INIT) {
|
if (tc.getTestType() == TestCase.TestType.RANDOM_INIT) {
|
||||||
log.info("Checking RANDOM_INIT test case: saved model vs. initialized model");
|
log.info("Checking RANDOM_INIT test case: saved model vs. initialized model");
|
||||||
//Checking randomly initialized model:
|
//Checking randomly initialized model:
|
||||||
File savedModel = new File(testBaseDir, IntegrationTestRunner.RANDOM_INIT_UNTRAINED_MODEL_FILENAME);
|
File savedModel = new File(testBaseDir, IntegrationTestRunner.RANDOM_INIT_UNTRAINED_MODEL_FILENAME);
|
||||||
Object config = tc.getConfiguration();
|
Object config = tc.getConfiguration();
|
||||||
if (config instanceof MultiLayerConfiguration) {
|
if (config instanceof NeuralNetConfiguration) {
|
||||||
MultiLayerConfiguration mlc = (MultiLayerConfiguration) config;
|
NeuralNetConfiguration mlc = (NeuralNetConfiguration) config;
|
||||||
mln = new MultiLayerNetwork(mlc);
|
mln = new MultiLayerNetwork(mlc);
|
||||||
mln.init();
|
mln.init();
|
||||||
m = mln;
|
m = mln;
|
||||||
|
|
||||||
MultiLayerNetwork loaded = MultiLayerNetwork.load(savedModel, true);
|
MultiLayerNetwork loaded = MultiLayerNetwork.load(savedModel, true);
|
||||||
assertEquals(loaded.getLayerWiseConfigurations(), mln.getLayerWiseConfigurations(), "Configs not equal");
|
assertEquals(loaded.getConfiguration(), mln.getConfiguration(), "Configs not equal");
|
||||||
assertEquals( loaded.params(), mln.params(), "Params not equal");
|
assertEquals( loaded.params(), mln.params(), "Params not equal");
|
||||||
assertEquals( loaded.paramTable(), mln.paramTable(), "Param table not equal");
|
assertEquals( loaded.getParamTable(), mln.getParamTable(), "Param table not equal");
|
||||||
} else if(config instanceof ComputationGraphConfiguration ){
|
} else if(config instanceof ComputationGraphConfiguration ){
|
||||||
ComputationGraphConfiguration cgc = (ComputationGraphConfiguration) config;
|
ComputationGraphConfiguration cgc = (ComputationGraphConfiguration) config;
|
||||||
cg = new ComputationGraph(cgc);
|
cg = new ComputationGraph(cgc);
|
||||||
|
@ -426,8 +426,8 @@ public class IntegrationTestRunner {
|
||||||
boolean isTbptt;
|
boolean isTbptt;
|
||||||
int tbpttLength;
|
int tbpttLength;
|
||||||
if(modelType == ModelType.MLN){
|
if(modelType == ModelType.MLN){
|
||||||
isTbptt = mln.getLayerWiseConfigurations().getBackpropType() == BackpropType.TruncatedBPTT;
|
isTbptt = mln.getConfiguration().getBackpropType() == BackpropType.TruncatedBPTT;
|
||||||
tbpttLength = mln.getLayerWiseConfigurations().getTbpttFwdLength();
|
tbpttLength = mln.getConfiguration().getTbpttFwdLength();
|
||||||
} else if(modelType == ModelType.CG) {
|
} else if(modelType == ModelType.CG) {
|
||||||
isTbptt = cg.getComputationGraphConfiguration().getBackpropType() == BackpropType.TruncatedBPTT;
|
isTbptt = cg.getComputationGraphConfiguration().getBackpropType() == BackpropType.TruncatedBPTT;
|
||||||
tbpttLength = cg.getComputationGraphConfiguration().getTbpttFwdLength();
|
tbpttLength = cg.getComputationGraphConfiguration().getTbpttFwdLength();
|
||||||
|
@ -606,7 +606,7 @@ public class IntegrationTestRunner {
|
||||||
if (modelType == ModelType.MLN) {
|
if (modelType == ModelType.MLN) {
|
||||||
ModelSerializer.writeModel(m, f, true);
|
ModelSerializer.writeModel(m, f, true);
|
||||||
MultiLayerNetwork restored = MultiLayerNetwork.load(f, true);
|
MultiLayerNetwork restored = MultiLayerNetwork.load(f, true);
|
||||||
assertEquals(mln.getLayerWiseConfigurations(), restored.getLayerWiseConfigurations());
|
assertEquals(mln.getConfiguration(), restored.getConfiguration());
|
||||||
assertEquals(mln.params(), restored.params());
|
assertEquals(mln.params(), restored.params());
|
||||||
} else if(modelType == ModelType.CG){
|
} else if(modelType == ModelType.CG){
|
||||||
ModelSerializer.writeModel(m, f, true);
|
ModelSerializer.writeModel(m, f, true);
|
||||||
|
@ -722,7 +722,7 @@ public class IntegrationTestRunner {
|
||||||
}
|
}
|
||||||
|
|
||||||
//Work out which layers, vertices etc we have seen - so we can (at the end of all tests) log our integration test coverage
|
//Work out which layers, vertices etc we have seen - so we can (at the end of all tests) log our integration test coverage
|
||||||
private static void collectCoverageInformation(Model m){
|
private static void collectCoverageInformation(IModel m){
|
||||||
boolean isMLN = (m instanceof MultiLayerNetwork);
|
boolean isMLN = (m instanceof MultiLayerNetwork);
|
||||||
MultiLayerNetwork mln = (isMLN ? (MultiLayerNetwork)m : null);
|
MultiLayerNetwork mln = (isMLN ? (MultiLayerNetwork)m : null);
|
||||||
ComputationGraph cg = (!isMLN ? (ComputationGraph)m : null);
|
ComputationGraph cg = (!isMLN ? (ComputationGraph)m : null);
|
||||||
|
@ -735,14 +735,14 @@ public class IntegrationTestRunner {
|
||||||
layers = cg.getLayers();
|
layers = cg.getLayers();
|
||||||
}
|
}
|
||||||
for (org.deeplearning4j.nn.api.Layer l : layers) {
|
for (org.deeplearning4j.nn.api.Layer l : layers) {
|
||||||
Layer lConf = l.conf().getLayer();
|
LayerConfiguration lConf = l.getLayerConfiguration();
|
||||||
layerConfClassesSeen.put(lConf.getClass(), layerConfClassesSeen.getOrDefault(lConf.getClass(), 0) + 1);
|
layerConfClassesSeen.put(lConf.getClass(), layerConfClassesSeen.getOrDefault(lConf.getClass(), 0) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Collect preprocessor coverage information:
|
//Collect preprocessor coverage information:
|
||||||
Collection<InputPreProcessor> preProcessors;
|
Collection<InputPreProcessor> preProcessors;
|
||||||
if (isMLN) {
|
if (isMLN) {
|
||||||
preProcessors = mln.getLayerWiseConfigurations().getInputPreProcessors().values();
|
preProcessors = mln.getConfiguration().getInputPreProcessors().values();
|
||||||
} else {
|
} else {
|
||||||
preProcessors = new ArrayList<>();
|
preProcessors = new ArrayList<>();
|
||||||
for (org.deeplearning4j.nn.conf.graph.GraphVertex gv : cg.getComputationGraphConfiguration().getVertices().values()) {
|
for (org.deeplearning4j.nn.conf.graph.GraphVertex gv : cg.getComputationGraphConfiguration().getVertices().values()) {
|
||||||
|
@ -767,7 +767,7 @@ public class IntegrationTestRunner {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void checkLayerClearance(Model m) {
|
private static void checkLayerClearance(IModel m) {
|
||||||
//Check that the input fields for all layers have been cleared
|
//Check that the input fields for all layers have been cleared
|
||||||
org.deeplearning4j.nn.api.Layer[] layers;
|
org.deeplearning4j.nn.api.Layer[] layers;
|
||||||
if (m instanceof MultiLayerNetwork) {
|
if (m instanceof MultiLayerNetwork) {
|
||||||
|
@ -801,7 +801,7 @@ public class IntegrationTestRunner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void validateLayerIterCounts(Model m, int expEpoch, int expIter){
|
private static void validateLayerIterCounts(IModel m, int expEpoch, int expIter){
|
||||||
//Check that the iteration and epoch counts - on the layers - are synced
|
//Check that the iteration and epoch counts - on the layers - are synced
|
||||||
org.deeplearning4j.nn.api.Layer[] layers;
|
org.deeplearning4j.nn.api.Layer[] layers;
|
||||||
if (m instanceof MultiLayerNetwork) {
|
if (m instanceof MultiLayerNetwork) {
|
||||||
|
@ -817,7 +817,7 @@ public class IntegrationTestRunner {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static Map<String,INDArray> getFrozenLayerParamCopies(Model m){
|
private static Map<String,INDArray> getFrozenLayerParamCopies(IModel m){
|
||||||
Map<String,INDArray> out = new LinkedHashMap<>();
|
Map<String,INDArray> out = new LinkedHashMap<>();
|
||||||
org.deeplearning4j.nn.api.Layer[] layers;
|
org.deeplearning4j.nn.api.Layer[] layers;
|
||||||
if (m instanceof MultiLayerNetwork) {
|
if (m instanceof MultiLayerNetwork) {
|
||||||
|
@ -832,7 +832,7 @@ public class IntegrationTestRunner {
|
||||||
if(m instanceof MultiLayerNetwork){
|
if(m instanceof MultiLayerNetwork){
|
||||||
paramPrefix = l.getIndex() + "_";
|
paramPrefix = l.getIndex() + "_";
|
||||||
} else {
|
} else {
|
||||||
paramPrefix = l.conf().getLayer().getLayerName() + "_";
|
paramPrefix = l.getLayerConfiguration().getLayerName() + "_";
|
||||||
}
|
}
|
||||||
Map<String,INDArray> paramTable = l.paramTable();
|
Map<String,INDArray> paramTable = l.paramTable();
|
||||||
for(Map.Entry<String,INDArray> e : paramTable.entrySet()){
|
for(Map.Entry<String,INDArray> e : paramTable.entrySet()){
|
||||||
|
@ -854,7 +854,7 @@ public class IntegrationTestRunner {
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void checkFrozenParams(Map<String,INDArray> copiesBeforeTraining, Model m){
|
public static void checkFrozenParams(Map<String,INDArray> copiesBeforeTraining, IModel m){
|
||||||
for(Map.Entry<String,INDArray> e : copiesBeforeTraining.entrySet()){
|
for(Map.Entry<String,INDArray> e : copiesBeforeTraining.entrySet()){
|
||||||
INDArray actual = m.getParam(e.getKey());
|
INDArray actual = m.getParam(e.getKey());
|
||||||
assertEquals(e.getValue(), actual, e.getKey());
|
assertEquals(e.getValue(), actual, e.getKey());
|
||||||
|
@ -939,7 +939,7 @@ public class IntegrationTestRunner {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isLayerConfig(Class<?> c) {
|
private static boolean isLayerConfig(Class<?> c) {
|
||||||
return Layer.class.isAssignableFrom(c);
|
return LayerConfiguration.class.isAssignableFrom(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isPreprocessorConfig(Class<?> c) {
|
private static boolean isPreprocessorConfig(Class<?> c) {
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
package org.deeplearning4j.integration;
|
package org.deeplearning4j.integration;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.deeplearning4j.nn.api.Model;
|
import net.brutex.ai.dnn.api.IModel;
|
||||||
import org.nd4j.autodiff.samediff.SameDiff;
|
import org.nd4j.autodiff.samediff.SameDiff;
|
||||||
import org.nd4j.evaluation.IEvaluation;
|
import org.nd4j.evaluation.IEvaluation;
|
||||||
import org.nd4j.linalg.api.ndarray.INDArray;
|
import org.nd4j.linalg.api.ndarray.INDArray;
|
||||||
|
@ -89,7 +89,7 @@ public abstract class TestCase {
|
||||||
/**
|
/**
|
||||||
* Required for pretrained models (testType == TestType.PRETRAINED)
|
* Required for pretrained models (testType == TestType.PRETRAINED)
|
||||||
*/
|
*/
|
||||||
public Model getPretrainedModel() throws Exception {
|
public IModel getPretrainedModel() throws Exception {
|
||||||
throw new RuntimeException("Implementations must override this method if used");
|
throw new RuntimeException("Implementations must override this method if used");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ package org.deeplearning4j.integration;
|
||||||
|
|
||||||
import org.apache.commons.compress.utils.IOUtils;
|
import org.apache.commons.compress.utils.IOUtils;
|
||||||
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.graph.ComputationGraph;
|
import org.deeplearning4j.nn.graph.ComputationGraph;
|
||||||
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
||||||
import org.deeplearning4j.util.ModelSerializer;
|
import org.deeplearning4j.util.ModelSerializer;
|
||||||
|
@ -48,15 +48,15 @@ public class TestUtils {
|
||||||
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
|
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
|
||||||
restored = ModelSerializer.restoreMultiLayerNetwork(bais, true);
|
restored = ModelSerializer.restoreMultiLayerNetwork(bais, true);
|
||||||
|
|
||||||
assertEquals(net.getLayerWiseConfigurations(), restored.getLayerWiseConfigurations());
|
assertEquals(net.getConfiguration(), restored.getConfiguration());
|
||||||
assertEquals(net.params(), restored.params());
|
assertEquals(net.params(), restored.params());
|
||||||
} catch (IOException e){
|
} catch (IOException e){
|
||||||
//Should never happen
|
//Should never happen
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Also check the MultiLayerConfiguration is serializable (required by Spark etc)
|
//Also check the NeuralNetConfiguration is serializable (required by Spark etc)
|
||||||
MultiLayerConfiguration conf = net.getLayerWiseConfigurations();
|
NeuralNetConfiguration conf = net.getConfiguration();
|
||||||
serializeDeserializeJava(conf);
|
serializeDeserializeJava(conf);
|
||||||
|
|
||||||
return restored;
|
return restored;
|
||||||
|
|
|
@ -80,12 +80,12 @@ public class CNN1DTestCases {
|
||||||
CharacterIterator iter = CharacterIterator.getShakespeareIterator(miniBatchSize,exampleLength);
|
CharacterIterator iter = CharacterIterator.getShakespeareIterator(miniBatchSize,exampleLength);
|
||||||
int nOut = iter.totalOutcomes();
|
int nOut = iter.totalOutcomes();
|
||||||
|
|
||||||
return new NeuralNetConfiguration.Builder()
|
return ((NeuralNetConfiguration.NeuralNetConfigurationBuilder)NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.FLOAT)
|
.dataType(DataType.FLOAT)
|
||||||
.seed(12345)
|
.seed(12345)
|
||||||
.weightInit(WeightInit.XAVIER)
|
.weightInit(WeightInit.XAVIER)
|
||||||
.updater(new Adam(0.01))
|
.updater(new Adam(0.01))
|
||||||
.convolutionMode(ConvolutionMode.Same)
|
.convolutionMode(ConvolutionMode.Same))
|
||||||
.graphBuilder()
|
.graphBuilder()
|
||||||
.addInputs("in")
|
.addInputs("in")
|
||||||
.layer("0", new Convolution1DLayer.Builder().nOut(32).activation(Activation.TANH).kernelSize(3).stride(1).build(), "in")
|
.layer("0", new Convolution1DLayer.Builder().nOut(32).activation(Activation.TANH).kernelSize(3).stride(1).build(), "in")
|
||||||
|
|
|
@ -32,7 +32,7 @@ import org.deeplearning4j.datasets.fetchers.DataSetType;
|
||||||
import org.deeplearning4j.datasets.iterator.EarlyTerminationDataSetIterator;
|
import org.deeplearning4j.datasets.iterator.EarlyTerminationDataSetIterator;
|
||||||
import org.deeplearning4j.datasets.iterator.impl.MnistDataSetIterator;
|
import org.deeplearning4j.datasets.iterator.impl.MnistDataSetIterator;
|
||||||
import org.deeplearning4j.datasets.iterator.impl.TinyImageNetDataSetIterator;
|
import org.deeplearning4j.datasets.iterator.impl.TinyImageNetDataSetIterator;
|
||||||
import org.deeplearning4j.nn.api.Model;
|
import net.brutex.ai.dnn.api.IModel;
|
||||||
import org.deeplearning4j.nn.api.OptimizationAlgorithm;
|
import org.deeplearning4j.nn.api.OptimizationAlgorithm;
|
||||||
import org.deeplearning4j.nn.conf.*;
|
import org.deeplearning4j.nn.conf.*;
|
||||||
import org.deeplearning4j.nn.conf.inputs.InputType;
|
import org.deeplearning4j.nn.conf.inputs.InputType;
|
||||||
|
@ -98,13 +98,13 @@ public class CNN2DTestCases {
|
||||||
int outputNum = 10; // The number of possible outcomes
|
int outputNum = 10; // The number of possible outcomes
|
||||||
int seed = 123;
|
int seed = 123;
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.FLOAT)
|
.dataType(DataType.FLOAT)
|
||||||
.seed(seed)
|
.seed(seed)
|
||||||
.l2(0.0005)
|
.l2(0.0005)
|
||||||
.weightInit(WeightInit.XAVIER)
|
.weightInit(WeightInit.XAVIER)
|
||||||
.updater(new Nesterovs(0.01, 0.9))
|
.updater(new Nesterovs(0.01, 0.9))
|
||||||
.list()
|
|
||||||
.layer(0, new ConvolutionLayer.Builder(5, 5)
|
.layer(0, new ConvolutionLayer.Builder(5, 5)
|
||||||
//nIn and nOut specify depth. nIn here is the nChannels and nOut is the number of filters to be applied
|
//nIn and nOut specify depth. nIn here is the nChannels and nOut is the number of filters to be applied
|
||||||
.nIn(nChannels)
|
.nIn(nChannels)
|
||||||
|
@ -132,7 +132,7 @@ public class CNN2DTestCases {
|
||||||
.nOut(outputNum)
|
.nOut(outputNum)
|
||||||
.activation(Activation.SOFTMAX)
|
.activation(Activation.SOFTMAX)
|
||||||
.build())
|
.build())
|
||||||
.setInputType(InputType.convolutionalFlat(28, 28, 1)) //See note below
|
.inputType(InputType.convolutionalFlat(28, 28, 1)) //See note below
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
return conf;
|
return conf;
|
||||||
|
@ -207,7 +207,7 @@ public class CNN2DTestCases {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Model getPretrainedModel() throws Exception {
|
public IModel getPretrainedModel() throws Exception {
|
||||||
VGG16 vgg16 = VGG16.builder()
|
VGG16 vgg16 = VGG16.builder()
|
||||||
.seed(12345)
|
.seed(12345)
|
||||||
.build();
|
.build();
|
||||||
|
@ -294,7 +294,7 @@ public class CNN2DTestCases {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Model getPretrainedModel() throws Exception {
|
public IModel getPretrainedModel() throws Exception {
|
||||||
int nClasses = 10;
|
int nClasses = 10;
|
||||||
int nBoxes = 5;
|
int nBoxes = 5;
|
||||||
double lambdaNoObj = 0.5;
|
double lambdaNoObj = 0.5;
|
||||||
|
@ -403,20 +403,20 @@ public class CNN2DTestCases {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Model getPretrainedModel() throws Exception {
|
public IModel getPretrainedModel() throws Exception {
|
||||||
|
|
||||||
Map<Integer, Double> lrSchedule = new HashMap<>();
|
Map<Integer, Double> lrSchedule = new HashMap<>();
|
||||||
lrSchedule.put(0, 0.01);
|
lrSchedule.put(0, 0.01);
|
||||||
lrSchedule.put(1000, 0.005);
|
lrSchedule.put(1000, 0.005);
|
||||||
lrSchedule.put(3000, 0.001);
|
lrSchedule.put(3000, 0.001);
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.FLOAT)
|
.dataType(DataType.FLOAT)
|
||||||
.seed(12345)
|
.seed(12345)
|
||||||
.l2(0.0005)
|
.l2(0.0005)
|
||||||
.weightInit(WeightInit.XAVIER)
|
.weightInit(WeightInit.XAVIER)
|
||||||
.updater(new Nesterovs(0.01, 0.9))
|
.updater(new Nesterovs(0.01, 0.9))
|
||||||
.list()
|
|
||||||
.layer(0, new ConvolutionLayer.Builder(5, 5)
|
.layer(0, new ConvolutionLayer.Builder(5, 5)
|
||||||
//nIn and nOut specify depth. nIn here is the nChannels and nOut is the number of filters to be applied
|
//nIn and nOut specify depth. nIn here is the nChannels and nOut is the number of filters to be applied
|
||||||
.nIn(1)
|
.nIn(1)
|
||||||
|
@ -446,7 +446,7 @@ public class CNN2DTestCases {
|
||||||
.nOut(10)
|
.nOut(10)
|
||||||
.activation(Activation.SOFTMAX)
|
.activation(Activation.SOFTMAX)
|
||||||
.build())
|
.build())
|
||||||
.setInputType(InputType.convolutionalFlat(28, 28, 1)) //See note below
|
.inputType(InputType.convolutionalFlat(28, 28, 1)) //See note below
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@ import org.deeplearning4j.datasets.iterator.impl.SingletonMultiDataSetIterator;
|
||||||
import org.deeplearning4j.integration.ModelType;
|
import org.deeplearning4j.integration.ModelType;
|
||||||
import org.deeplearning4j.integration.TestCase;
|
import org.deeplearning4j.integration.TestCase;
|
||||||
import org.deeplearning4j.nn.conf.ConvolutionMode;
|
import org.deeplearning4j.nn.conf.ConvolutionMode;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.inputs.InputType;
|
import org.deeplearning4j.nn.conf.inputs.InputType;
|
||||||
import org.deeplearning4j.nn.conf.layers.Convolution3D;
|
import org.deeplearning4j.nn.conf.layers.Convolution3D;
|
||||||
|
@ -76,13 +75,13 @@ public class CNN3DTestCases {
|
||||||
int outputNum = 10; // The number of possible outcomes
|
int outputNum = 10; // The number of possible outcomes
|
||||||
int seed = 123;
|
int seed = 123;
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.seed(seed)
|
.seed(seed)
|
||||||
.l2(0.0005)
|
.l2(0.0005)
|
||||||
.weightInit(WeightInit.XAVIER)
|
.weightInit(WeightInit.XAVIER)
|
||||||
.updater(new Nesterovs(0.01, 0.9))
|
.updater(new Nesterovs(0.01, 0.9))
|
||||||
.convolutionMode(ConvolutionMode.Same)
|
.convolutionMode(ConvolutionMode.Same)
|
||||||
.list()
|
|
||||||
.layer(new Convolution3D.Builder(3,3,3)
|
.layer(new Convolution3D.Builder(3,3,3)
|
||||||
.dataFormat(Convolution3D.DataFormat.NCDHW)
|
.dataFormat(Convolution3D.DataFormat.NCDHW)
|
||||||
.nIn(nChannels)
|
.nIn(nChannels)
|
||||||
|
@ -98,7 +97,7 @@ public class CNN3DTestCases {
|
||||||
.nOut(outputNum)
|
.nOut(outputNum)
|
||||||
.activation(Activation.SOFTMAX)
|
.activation(Activation.SOFTMAX)
|
||||||
.build())
|
.build())
|
||||||
.setInputType(InputType.convolutional3D(8,8,8,nChannels))
|
.inputType(InputType.convolutional3D(8,8,8,nChannels))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
return conf;
|
return conf;
|
||||||
|
|
|
@ -28,7 +28,6 @@ import org.datavec.api.split.FileSplit;
|
||||||
import org.deeplearning4j.datasets.datavec.RecordReaderDataSetIterator;
|
import org.deeplearning4j.datasets.datavec.RecordReaderDataSetIterator;
|
||||||
import org.deeplearning4j.datasets.iterator.EarlyTerminationDataSetIterator;
|
import org.deeplearning4j.datasets.iterator.EarlyTerminationDataSetIterator;
|
||||||
import org.deeplearning4j.datasets.iterator.impl.MnistDataSetIterator;
|
import org.deeplearning4j.datasets.iterator.impl.MnistDataSetIterator;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.inputs.InputType;
|
import org.deeplearning4j.nn.conf.inputs.InputType;
|
||||||
import org.deeplearning4j.nn.conf.layers.DenseLayer;
|
import org.deeplearning4j.nn.conf.layers.DenseLayer;
|
||||||
|
@ -93,7 +92,7 @@ public class MLPTestCases {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getConfiguration() {
|
public Object getConfiguration() {
|
||||||
return new NeuralNetConfiguration.Builder()
|
return NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.FLOAT)
|
.dataType(DataType.FLOAT)
|
||||||
.seed(12345)
|
.seed(12345)
|
||||||
.updater(new Adam(new MapSchedule.Builder(ScheduleType.ITERATION)
|
.updater(new Adam(new MapSchedule.Builder(ScheduleType.ITERATION)
|
||||||
|
@ -104,13 +103,13 @@ public class MLPTestCases {
|
||||||
.add(14, 1e-2)
|
.add(14, 1e-2)
|
||||||
.build()))
|
.build()))
|
||||||
.l1(1e-3).l2(1e-3)
|
.l1(1e-3).l2(1e-3)
|
||||||
.list()
|
|
||||||
.layer(new DenseLayer.Builder().activation(Activation.TANH).nOut(64).build())
|
.layer(new DenseLayer.Builder().activation(Activation.TANH).nOut(64).build())
|
||||||
.layer(new OutputLayer.Builder().nOut(10)
|
.layer(new OutputLayer.Builder().nOut(10)
|
||||||
.lossFunction(LossFunctions.LossFunction.MCXENT)
|
.lossFunction(LossFunctions.LossFunction.MCXENT)
|
||||||
.activation(Activation.SOFTMAX)
|
.activation(Activation.SOFTMAX)
|
||||||
.build())
|
.build())
|
||||||
.setInputType(InputType.convolutionalFlat(28,28,1))
|
.inputType(InputType.convolutionalFlat(28,28,1))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,11 +197,11 @@ public class MLPTestCases {
|
||||||
int numHiddenNodes = 20;
|
int numHiddenNodes = 20;
|
||||||
|
|
||||||
//log.info("Build model....");
|
//log.info("Build model....");
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.FLOAT)
|
.dataType(DataType.FLOAT)
|
||||||
.seed(seed)
|
.seed(seed)
|
||||||
.updater(new Nesterovs(learningRate, 0.9))
|
.updater(new Nesterovs(learningRate, 0.9))
|
||||||
.list()
|
|
||||||
.layer(0, new DenseLayer.Builder().nIn(numInputs).nOut(numHiddenNodes)
|
.layer(0, new DenseLayer.Builder().nIn(numInputs).nOut(numHiddenNodes)
|
||||||
.weightInit(WeightInit.XAVIER)
|
.weightInit(WeightInit.XAVIER)
|
||||||
.activation(Activation.RELU)
|
.activation(Activation.RELU)
|
||||||
|
|
|
@ -112,20 +112,20 @@ public class RNNTestCases {
|
||||||
int lstmLayerSize = 200; //Number of units in each GravesLSTM layer
|
int lstmLayerSize = 200; //Number of units in each GravesLSTM layer
|
||||||
int tbpttLength = 50; //Length for truncated backpropagation through time. i.e., do parameter updates ever 50 characters
|
int tbpttLength = 50; //Length for truncated backpropagation through time. i.e., do parameter updates ever 50 characters
|
||||||
|
|
||||||
return new NeuralNetConfiguration.Builder()
|
return NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.FLOAT)
|
.dataType(DataType.FLOAT)
|
||||||
.seed(12345)
|
.seed(12345)
|
||||||
.l2(0.001)
|
.l2(0.001)
|
||||||
.weightInit(WeightInit.XAVIER)
|
.weightInit(WeightInit.XAVIER)
|
||||||
.updater(new Adam(1e-3))
|
.updater(new Adam(1e-3))
|
||||||
.list()
|
|
||||||
.layer(0, new LSTM.Builder().nIn(iter.inputColumns()).nOut(lstmLayerSize)
|
.layer(0, new LSTM.Builder().nIn(iter.inputColumns()).nOut(lstmLayerSize)
|
||||||
.activation(Activation.TANH).build())
|
.activation(Activation.TANH).build())
|
||||||
.layer(1, new LSTM.Builder().nIn(lstmLayerSize).nOut(lstmLayerSize)
|
.layer(1, new LSTM.Builder().nIn(lstmLayerSize).nOut(lstmLayerSize)
|
||||||
.activation(Activation.TANH).build())
|
.activation(Activation.TANH).build())
|
||||||
.layer(2, new RnnOutputLayer.Builder(LossFunctions.LossFunction.MCXENT).activation(Activation.SOFTMAX) //MCXENT + softmax for classification
|
.layer(2, new RnnOutputLayer.Builder(LossFunctions.LossFunction.MCXENT).activation(Activation.SOFTMAX) //MCXENT + softmax for classification
|
||||||
.nIn(lstmLayerSize).nOut(nOut).build())
|
.nIn(lstmLayerSize).nOut(nOut).build())
|
||||||
.backpropType(BackpropType.TruncatedBPTT).tBPTTForwardLength(tbpttLength).tBPTTBackwardLength(tbpttLength)
|
.backpropType(BackpropType.TruncatedBPTT).tbpttFwdLength(tbpttLength).tbpttBackLength(tbpttLength)
|
||||||
|
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
@ -195,19 +195,19 @@ public class RNNTestCases {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getConfiguration() throws Exception {
|
public Object getConfiguration() throws Exception {
|
||||||
return new NeuralNetConfiguration.Builder()
|
return NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.FLOAT)
|
.dataType(DataType.FLOAT)
|
||||||
.seed(12345)
|
.seed(12345)
|
||||||
.updater(new Adam(5e-2))
|
.updater(new Adam(5e-2))
|
||||||
.l1(1e-3).l2(1e-3)
|
.l1(1e-3).l2(1e-3)
|
||||||
.list()
|
|
||||||
.layer(0, new LSTM.Builder().activation(Activation.TANH).nOut(10).build())
|
.layer(0, new LSTM.Builder().activation(Activation.TANH).nOut(10).build())
|
||||||
.layer(new GlobalPoolingLayer.Builder().poolingType(PoolingType.AVG).build())
|
.layer(new GlobalPoolingLayer.Builder().poolingType(PoolingType.AVG).build())
|
||||||
.layer(new OutputLayer.Builder().nOut(6)
|
.layer(new OutputLayer.Builder().nOut(6)
|
||||||
.lossFunction(LossFunctions.LossFunction.MCXENT)
|
.lossFunction(LossFunctions.LossFunction.MCXENT)
|
||||||
.activation(Activation.SOFTMAX)
|
.activation(Activation.SOFTMAX)
|
||||||
.build())
|
.build())
|
||||||
.setInputType(InputType.recurrent(1))
|
.inputType(InputType.recurrent(1))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,19 +316,19 @@ public class RNNTestCases {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getConfiguration() throws Exception {
|
public Object getConfiguration() throws Exception {
|
||||||
return new NeuralNetConfiguration.Builder()
|
return NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.FLOAT)
|
.dataType(DataType.FLOAT)
|
||||||
.seed(12345)
|
.seed(12345)
|
||||||
.updater(new Adam(5e-2))
|
.updater(new Adam(5e-2))
|
||||||
.l1(1e-3).l2(1e-3)
|
.l1(1e-3).l2(1e-3)
|
||||||
.list()
|
|
||||||
.layer(0, new Bidirectional(new LSTM.Builder().activation(Activation.TANH).nOut(10).build()))
|
.layer(0, new Bidirectional(new LSTM.Builder().activation(Activation.TANH).nOut(10).build()))
|
||||||
.layer(new GlobalPoolingLayer.Builder().poolingType(PoolingType.AVG).build())
|
.layer(new GlobalPoolingLayer.Builder().poolingType(PoolingType.AVG).build())
|
||||||
.layer(new OutputLayer.Builder().nOut(6)
|
.layer(new OutputLayer.Builder().nOut(6)
|
||||||
.lossFunction(LossFunctions.LossFunction.MCXENT)
|
.lossFunction(LossFunctions.LossFunction.MCXENT)
|
||||||
.activation(Activation.SOFTMAX)
|
.activation(Activation.SOFTMAX)
|
||||||
.build())
|
.build())
|
||||||
.setInputType(InputType.recurrent(1))
|
.inputType(InputType.recurrent(1))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,13 +72,13 @@ public class UnsupervisedTestCases {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getConfiguration() {
|
public Object getConfiguration() {
|
||||||
return new NeuralNetConfiguration.Builder()
|
return NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.FLOAT)
|
.dataType(DataType.FLOAT)
|
||||||
.seed(12345)
|
.seed(12345)
|
||||||
.updater(new Adam(1e-3))
|
.updater(new Adam(1e-3))
|
||||||
.weightInit(WeightInit.XAVIER)
|
.weightInit(WeightInit.XAVIER)
|
||||||
.l2(1e-4)
|
.l2(1e-4)
|
||||||
.list()
|
|
||||||
.layer(0, new VariationalAutoencoder.Builder()
|
.layer(0, new VariationalAutoencoder.Builder()
|
||||||
.activation(Activation.TANH)
|
.activation(Activation.TANH)
|
||||||
.encoderLayerSizes(256, 256) //2 encoder layers, each of size 256
|
.encoderLayerSizes(256, 256) //2 encoder layers, each of size 256
|
||||||
|
|
|
@ -66,9 +66,9 @@ allprojects { Project proj ->
|
||||||
|
|
||||||
plugins.withType(JavaPlugin) {
|
plugins.withType(JavaPlugin) {
|
||||||
sourceCompatibility = JavaVersion.VERSION_11
|
sourceCompatibility = JavaVersion.VERSION_11
|
||||||
targetCompatibility = JavaVersion.VERSION_1_8
|
targetCompatibility = JavaVersion.VERSION_11
|
||||||
tasks.withType(JavaCompile) {
|
tasks.withType(JavaCompile) {
|
||||||
options.release = 8
|
options.release = 11
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
||||||
|
@ -86,7 +86,6 @@ allprojects { Project proj ->
|
||||||
testImplementation 'org.junit.jupiter:junit-jupiter-engine'
|
testImplementation 'org.junit.jupiter:junit-jupiter-engine'
|
||||||
testImplementation 'org.junit.jupiter:junit-jupiter-api'
|
testImplementation 'org.junit.jupiter:junit-jupiter-api'
|
||||||
testImplementation 'org.junit.jupiter:junit-jupiter-params'
|
testImplementation 'org.junit.jupiter:junit-jupiter-params'
|
||||||
|
|
||||||
implementation "org.slf4j:slf4j-api"
|
implementation "org.slf4j:slf4j-api"
|
||||||
implementation "org.slf4j:slf4j-simple"
|
implementation "org.slf4j:slf4j-simple"
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* ******************************************************************************
|
||||||
|
* *
|
||||||
|
* * This program and the accompanying materials are made available under the
|
||||||
|
* * terms of the Apache License, Version 2.0 which is available at
|
||||||
|
* * https://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
* *
|
||||||
|
* * See the NOTICE file distributed with this work for additional
|
||||||
|
* * information regarding copyright ownership.
|
||||||
|
* * Unless required by applicable law or agreed to in writing, software
|
||||||
|
* * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* * License for the specific language governing permissions and limitations
|
||||||
|
* * under the License.
|
||||||
|
* *
|
||||||
|
* * SPDX-License-Identifier: Apache-2.0
|
||||||
|
* *****************************************************************************
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.brutex.ai.dnn.core.util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ANSI colour codes
|
||||||
|
*/
|
||||||
|
public enum ANSI {
|
||||||
|
BLACK("\u001B[30m"),
|
||||||
|
RED("\u001B[31m"),
|
||||||
|
GREEN("\u001B[32m"),
|
||||||
|
YELLOW("\u001B[33m"),
|
||||||
|
BLUE("\u001B[34m"),
|
||||||
|
PURPLE("\u001B[35m"),
|
||||||
|
CYAN("\u001B[36m"),
|
||||||
|
WHITE("\u001B[37m"),
|
||||||
|
|
||||||
|
ANSI_RESET("\u001B[0m"),
|
||||||
|
|
||||||
|
BLACK_BACKGROUND("\u001B[40m"),
|
||||||
|
RED_BACKGROUND("\u001B[41m"),
|
||||||
|
GREEN_BACKGROUND("\u001B[42m"),
|
||||||
|
YELLOW_BACKGROUND("\u001B[43m"),
|
||||||
|
BLUE_BACKGROUND("\u001B[44m"),
|
||||||
|
PURPLE_BACKGROUND("\u001B[45m"),
|
||||||
|
CYAN_BACKGROUND("\u001B[46m"),
|
||||||
|
WHITE_BACKGROUND("\u001B[47m");
|
||||||
|
|
||||||
|
String code;
|
||||||
|
ANSI(String code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
}
|
|
@ -23,8 +23,8 @@ package org.deeplearning4j.core.listener;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.brutex.ai.dnn.api.IModel;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.deeplearning4j.nn.api.Model;
|
|
||||||
import org.deeplearning4j.optimize.api.TrainingListener;
|
import org.deeplearning4j.optimize.api.TrainingListener;
|
||||||
import org.nd4j.linalg.api.ndarray.INDArray;
|
import org.nd4j.linalg.api.ndarray.INDArray;
|
||||||
import oshi.json.SystemInfo;
|
import oshi.json.SystemInfo;
|
||||||
|
@ -56,12 +56,12 @@ public class SystemInfoFilePrintListener implements TrainingListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void iterationDone(Model model, int iteration, int epoch) {
|
public void iterationDone(IModel model, int iteration, int epoch) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEpochStart(Model model) {
|
public void onEpochStart(IModel model) {
|
||||||
if(!printOnEpochStart || printFileTarget == null)
|
if(!printOnEpochStart || printFileTarget == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ public class SystemInfoFilePrintListener implements TrainingListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEpochEnd(Model model) {
|
public void onEpochEnd(IModel model) {
|
||||||
if(!printOnEpochEnd || printFileTarget == null)
|
if(!printOnEpochEnd || printFileTarget == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ public class SystemInfoFilePrintListener implements TrainingListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onForwardPass(Model model, List<INDArray> activations) {
|
public void onForwardPass(IModel model, List<INDArray> activations) {
|
||||||
if(!printOnBackwardPass || printFileTarget == null)
|
if(!printOnBackwardPass || printFileTarget == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ public class SystemInfoFilePrintListener implements TrainingListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onForwardPass(Model model, Map<String, INDArray> activations) {
|
public void onForwardPass(IModel model, Map<String, INDArray> activations) {
|
||||||
if(!printOnForwardPass || printFileTarget == null)
|
if(!printOnForwardPass || printFileTarget == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ public class SystemInfoFilePrintListener implements TrainingListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onGradientCalculation(Model model) {
|
public void onGradientCalculation(IModel model) {
|
||||||
if(!printOnGradientCalculation || printFileTarget == null)
|
if(!printOnGradientCalculation || printFileTarget == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ public class SystemInfoFilePrintListener implements TrainingListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBackwardPass(Model model) {
|
public void onBackwardPass(IModel model) {
|
||||||
if(!printOnBackwardPass || printFileTarget == null)
|
if(!printOnBackwardPass || printFileTarget == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ package org.deeplearning4j.core.listener;
|
||||||
|
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.deeplearning4j.nn.api.Model;
|
import net.brutex.ai.dnn.api.IModel;
|
||||||
import org.deeplearning4j.optimize.api.TrainingListener;
|
import org.deeplearning4j.optimize.api.TrainingListener;
|
||||||
import org.nd4j.linalg.api.ndarray.INDArray;
|
import org.nd4j.linalg.api.ndarray.INDArray;
|
||||||
import oshi.json.SystemInfo;
|
import oshi.json.SystemInfo;
|
||||||
|
@ -49,12 +49,12 @@ public class SystemInfoPrintListener implements TrainingListener {
|
||||||
|
|
||||||
private static final String SYSTEM_INFO = "System info on epoch end: ";
|
private static final String SYSTEM_INFO = "System info on epoch end: ";
|
||||||
@Override
|
@Override
|
||||||
public void iterationDone(Model model, int iteration, int epoch) {
|
public void iterationDone(IModel model, int iteration, int epoch) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEpochStart(Model model) {
|
public void onEpochStart(IModel model) {
|
||||||
if(!printOnEpochStart)
|
if(!printOnEpochStart)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ public class SystemInfoPrintListener implements TrainingListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEpochEnd(Model model) {
|
public void onEpochEnd(IModel model) {
|
||||||
if(!printOnEpochEnd)
|
if(!printOnEpochEnd)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ public class SystemInfoPrintListener implements TrainingListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onForwardPass(Model model, List<INDArray> activations) {
|
public void onForwardPass(IModel model, List<INDArray> activations) {
|
||||||
if(!printOnBackwardPass)
|
if(!printOnBackwardPass)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ public class SystemInfoPrintListener implements TrainingListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onForwardPass(Model model, Map<String, INDArray> activations) {
|
public void onForwardPass(IModel model, Map<String, INDArray> activations) {
|
||||||
if(!printOnForwardPass)
|
if(!printOnForwardPass)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ public class SystemInfoPrintListener implements TrainingListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onGradientCalculation(Model model) {
|
public void onGradientCalculation(IModel model) {
|
||||||
if(!printOnGradientCalculation)
|
if(!printOnGradientCalculation)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ public class SystemInfoPrintListener implements TrainingListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBackwardPass(Model model) {
|
public void onBackwardPass(IModel model) {
|
||||||
if(!printOnBackwardPass)
|
if(!printOnBackwardPass)
|
||||||
return;
|
return;
|
||||||
SystemInfo systemInfo = new SystemInfo();
|
SystemInfo systemInfo = new SystemInfo();
|
||||||
|
|
|
@ -21,13 +21,13 @@
|
||||||
package org.deeplearning4j.core.util;
|
package org.deeplearning4j.core.util;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.brutex.ai.dnn.api.IModel;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.deeplearning4j.common.util.DL4JFileUtils;
|
import org.deeplearning4j.common.util.DL4JFileUtils;
|
||||||
import org.deeplearning4j.common.config.DL4JSystemProperties;
|
import org.deeplearning4j.common.config.DL4JSystemProperties;
|
||||||
import org.deeplearning4j.nn.api.Model;
|
|
||||||
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.modelimport.keras.KerasModelImport;
|
import org.deeplearning4j.nn.modelimport.keras.KerasModelImport;
|
||||||
import org.deeplearning4j.util.ModelSerializer;
|
import org.deeplearning4j.util.ModelSerializer;
|
||||||
import org.nd4j.linalg.dataset.api.preprocessor.Normalizer;
|
import org.nd4j.linalg.dataset.api.preprocessor.Normalizer;
|
||||||
|
@ -80,7 +80,7 @@ public class ModelGuesser {
|
||||||
//note here that we load json BEFORE YAML. YAML
|
//note here that we load json BEFORE YAML. YAML
|
||||||
//turns out to load just fine *accidentally*
|
//turns out to load just fine *accidentally*
|
||||||
try {
|
try {
|
||||||
return MultiLayerConfiguration.fromJson(input);
|
return NeuralNetConfiguration.fromJson(input);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn("Tried multi layer config from json", e);
|
log.warn("Tried multi layer config from json", e);
|
||||||
try {
|
try {
|
||||||
|
@ -96,7 +96,7 @@ public class ModelGuesser {
|
||||||
} catch (Exception e3) {
|
} catch (Exception e3) {
|
||||||
log.warn("Tried computation graph from json");
|
log.warn("Tried computation graph from json");
|
||||||
try {
|
try {
|
||||||
return MultiLayerConfiguration.fromYaml(input);
|
return NeuralNetConfiguration.fromYaml(input);
|
||||||
} catch (Exception e4) {
|
} catch (Exception e4) {
|
||||||
log.warn("Tried multi layer configuration from yaml");
|
log.warn("Tried multi layer configuration from yaml");
|
||||||
try {
|
try {
|
||||||
|
@ -142,7 +142,7 @@ public class ModelGuesser {
|
||||||
* @return the loaded model
|
* @return the loaded model
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static Model loadModelGuess(String path) throws Exception {
|
public static IModel loadModelGuess(String path) throws Exception {
|
||||||
try {
|
try {
|
||||||
return ModelSerializer.restoreMultiLayerNetwork(new File(path), true);
|
return ModelSerializer.restoreMultiLayerNetwork(new File(path), true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -185,7 +185,7 @@ public class ModelGuesser {
|
||||||
* @return the loaded model
|
* @return the loaded model
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static Model loadModelGuess(InputStream stream) throws Exception {
|
public static IModel loadModelGuess(InputStream stream) throws Exception {
|
||||||
return loadModelGuess(stream, null);
|
return loadModelGuess(stream, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,7 +194,7 @@ public class ModelGuesser {
|
||||||
* @param stream Stream of the model file
|
* @param stream Stream of the model file
|
||||||
* @param tempDirectory Temporary/working directory. May be null.
|
* @param tempDirectory Temporary/working directory. May be null.
|
||||||
*/
|
*/
|
||||||
public static Model loadModelGuess(InputStream stream, File tempDirectory) throws Exception {
|
public static IModel loadModelGuess(InputStream stream, File tempDirectory) throws Exception {
|
||||||
//Currently (Nov 2017): KerasModelImport doesn't support loading from input streams
|
//Currently (Nov 2017): KerasModelImport doesn't support loading from input streams
|
||||||
//Simplest solution here: write to a temporary file
|
//Simplest solution here: write to a temporary file
|
||||||
File f;
|
File f;
|
||||||
|
|
|
@ -26,6 +26,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import org.deeplearning4j.common.config.DL4JClassLoading;
|
import org.deeplearning4j.common.config.DL4JClassLoading;
|
||||||
import org.deeplearning4j.nn.api.Layer;
|
import org.deeplearning4j.nn.api.Layer;
|
||||||
import org.deeplearning4j.nn.conf.layers.ConvolutionLayer;
|
import org.deeplearning4j.nn.conf.layers.ConvolutionLayer;
|
||||||
|
import org.deeplearning4j.nn.conf.layers.LayerConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.layers.SubsamplingLayer;
|
import org.deeplearning4j.nn.conf.layers.SubsamplingLayer;
|
||||||
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
||||||
import org.deeplearning4j.optimize.listeners.CollectScoresListener;
|
import org.deeplearning4j.optimize.listeners.CollectScoresListener;
|
||||||
|
@ -99,7 +100,7 @@ public class LayerHelperValidationUtil {
|
||||||
|
|
||||||
//Don't allow fallback:
|
//Don't allow fallback:
|
||||||
for(Layer l : netOrig.getLayers()){
|
for(Layer l : netOrig.getLayers()){
|
||||||
org.deeplearning4j.nn.conf.layers.Layer lConf = l.conf().getLayer();
|
LayerConfiguration lConf = l.getLayerConfiguration();
|
||||||
if(lConf instanceof ConvolutionLayer){
|
if(lConf instanceof ConvolutionLayer){
|
||||||
((ConvolutionLayer) lConf).setCudnnAllowFallback(false);
|
((ConvolutionLayer) lConf).setCudnnAllowFallback(false);
|
||||||
} else if(lConf instanceof SubsamplingLayer){
|
} else if(lConf instanceof SubsamplingLayer){
|
||||||
|
@ -108,12 +109,12 @@ public class LayerHelperValidationUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MultiLayerNetwork net1NoHelper = new MultiLayerNetwork(netOrig.getLayerWiseConfigurations().clone());
|
MultiLayerNetwork net1NoHelper = new MultiLayerNetwork(netOrig.getConfiguration().clone());
|
||||||
net1NoHelper.init();
|
net1NoHelper.init();
|
||||||
log.info("Removing all layer helpers from network copy 1");
|
log.info("Removing all layer helpers from network copy 1");
|
||||||
removeHelpers(net1NoHelper.getLayers(), null);
|
removeHelpers(net1NoHelper.getLayers(), null);
|
||||||
|
|
||||||
MultiLayerNetwork net2With = new MultiLayerNetwork(netOrig.getLayerWiseConfigurations().clone());
|
MultiLayerNetwork net2With = new MultiLayerNetwork(netOrig.getConfiguration().clone());
|
||||||
net2With.init();
|
net2With.init();
|
||||||
net2With.params().assign(netOrig.params());
|
net2With.params().assign(netOrig.params());
|
||||||
log.info("Removing all except for specified helpers from network copy 2: " + t.getAllowHelpersForClasses());
|
log.info("Removing all except for specified helpers from network copy 2: " + t.getAllowHelpersForClasses());
|
||||||
|
@ -133,7 +134,7 @@ public class LayerHelperValidationUtil {
|
||||||
enableCppHelpers();
|
enableCppHelpers();
|
||||||
}
|
}
|
||||||
List<INDArray> ff2 = net2With.feedForward(t.getFeatures(), train);
|
List<INDArray> ff2 = net2With.feedForward(t.getFeatures(), train);
|
||||||
List<String> paramKeys = new ArrayList<>(net1NoHelper.paramTable().keySet());
|
List<String> paramKeys = new ArrayList<>(net1NoHelper.getParamTable().keySet());
|
||||||
Collections.sort(paramKeys);
|
Collections.sort(paramKeys);
|
||||||
for (String p : paramKeys) {
|
for (String p : paramKeys) {
|
||||||
INDArray p1 = net1NoHelper.getParam(p);
|
INDArray p1 = net1NoHelper.getParam(p);
|
||||||
|
@ -224,7 +225,7 @@ public class LayerHelperValidationUtil {
|
||||||
}
|
}
|
||||||
net2With.computeGradientAndScore();
|
net2With.computeGradientAndScore();
|
||||||
|
|
||||||
List<String> paramKeys = new ArrayList<>(net1NoHelper.paramTable().keySet());
|
List<String> paramKeys = new ArrayList<>(net1NoHelper.getParamTable().keySet());
|
||||||
Collections.sort(paramKeys);
|
Collections.sort(paramKeys);
|
||||||
for(String p : paramKeys){
|
for(String p : paramKeys){
|
||||||
INDArray g1 = net1NoHelper.gradient().gradientForVariable().get(p);
|
INDArray g1 = net1NoHelper.gradient().gradientForVariable().get(p);
|
||||||
|
@ -252,7 +253,7 @@ public class LayerHelperValidationUtil {
|
||||||
Preconditions.checkNotNull(t.getData(), "DataSetIterator is not set (null)");
|
Preconditions.checkNotNull(t.getData(), "DataSetIterator is not set (null)");
|
||||||
log.info("Testing run-to-run consistency of training with layer helper");
|
log.info("Testing run-to-run consistency of training with layer helper");
|
||||||
|
|
||||||
net2With = new MultiLayerNetwork(netOrig.getLayerWiseConfigurations().clone());
|
net2With = new MultiLayerNetwork(netOrig.getConfiguration().clone());
|
||||||
net2With.init();
|
net2With.init();
|
||||||
net2With.params().assign(netOrig.params());
|
net2With.params().assign(netOrig.params());
|
||||||
log.info("Removing all except for specified layer helpers from network copy 2: " + t.getAllowHelpersForClasses());
|
log.info("Removing all except for specified layer helpers from network copy 2: " + t.getAllowHelpersForClasses());
|
||||||
|
@ -264,7 +265,7 @@ public class LayerHelperValidationUtil {
|
||||||
|
|
||||||
for( int i=0; i<2; i++ ) {
|
for( int i=0; i<2; i++ ) {
|
||||||
|
|
||||||
net2With = new MultiLayerNetwork(netOrig.getLayerWiseConfigurations().clone());
|
net2With = new MultiLayerNetwork(netOrig.getConfiguration().clone());
|
||||||
net2With.init();
|
net2With.init();
|
||||||
net2With.params().assign(netOrig.params());
|
net2With.params().assign(netOrig.params());
|
||||||
log.info("Removing all except for specified layer helpers from network copy 2: " + t.getAllowHelpersForClasses());
|
log.info("Removing all except for specified layer helpers from network copy 2: " + t.getAllowHelpersForClasses());
|
||||||
|
|
|
@ -23,19 +23,15 @@ package org.deeplearning4j;
|
||||||
import org.deeplearning4j.datasets.iterator.EarlyTerminationDataSetIterator;
|
import org.deeplearning4j.datasets.iterator.EarlyTerminationDataSetIterator;
|
||||||
import org.deeplearning4j.datasets.iterator.impl.MnistDataSetIterator;
|
import org.deeplearning4j.datasets.iterator.impl.MnistDataSetIterator;
|
||||||
import org.deeplearning4j.nn.api.OptimizationAlgorithm;
|
import org.deeplearning4j.nn.api.OptimizationAlgorithm;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.nd4j.common.resources.Resources;
|
|
||||||
import org.nd4j.linalg.activations.Activation;
|
import org.nd4j.linalg.activations.Activation;
|
||||||
import org.nd4j.linalg.dataset.api.iterator.DataSetIterator;
|
import org.nd4j.linalg.dataset.api.iterator.DataSetIterator;
|
||||||
import org.nd4j.linalg.factory.Nd4j;
|
|
||||||
import org.nd4j.linalg.learning.config.RmsProp;
|
import org.nd4j.linalg.learning.config.RmsProp;
|
||||||
import org.nd4j.linalg.lossfunctions.LossFunctions;
|
import org.nd4j.linalg.lossfunctions.LossFunctions;
|
||||||
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
|
|
||||||
//@Ignore
|
//@Ignore
|
||||||
|
@ -44,8 +40,8 @@ public class RandomTests extends BaseDL4JTest {
|
||||||
@Test
|
@Test
|
||||||
public void testReproduce() throws Exception {
|
public void testReproduce() throws Exception {
|
||||||
|
|
||||||
final MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().updater(new RmsProp())
|
final NeuralNetConfiguration conf = NeuralNetConfiguration.builder().updater(new RmsProp())
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).list()
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.layer(0, new org.deeplearning4j.nn.conf.layers.DenseLayer.Builder().nIn(28 * 28).nOut(10)
|
.layer(0, new org.deeplearning4j.nn.conf.layers.DenseLayer.Builder().nIn(28 * 28).nOut(10)
|
||||||
.activation(Activation.TANH).build())
|
.activation(Activation.TANH).build())
|
||||||
.layer(1, new org.deeplearning4j.nn.conf.layers.OutputLayer.Builder(
|
.layer(1, new org.deeplearning4j.nn.conf.layers.OutputLayer.Builder(
|
||||||
|
|
|
@ -23,7 +23,7 @@ package org.deeplearning4j;
|
||||||
import org.apache.commons.compress.utils.IOUtils;
|
import org.apache.commons.compress.utils.IOUtils;
|
||||||
import org.deeplearning4j.nn.api.Layer;
|
import org.deeplearning4j.nn.api.Layer;
|
||||||
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.RNNFormat;
|
import org.deeplearning4j.nn.conf.RNNFormat;
|
||||||
import org.deeplearning4j.nn.conf.layers.BaseLayer;
|
import org.deeplearning4j.nn.conf.layers.BaseLayer;
|
||||||
import org.deeplearning4j.nn.conf.layers.samediff.AbstractSameDiffLayer;
|
import org.deeplearning4j.nn.conf.layers.samediff.AbstractSameDiffLayer;
|
||||||
|
@ -66,15 +66,15 @@ public class TestUtils {
|
||||||
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
|
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
|
||||||
restored = ModelSerializer.restoreMultiLayerNetwork(bais, true);
|
restored = ModelSerializer.restoreMultiLayerNetwork(bais, true);
|
||||||
|
|
||||||
assertEquals(net.getLayerWiseConfigurations(), restored.getLayerWiseConfigurations());
|
assertEquals(net.getConfiguration(), restored.getConfiguration());
|
||||||
assertEquals(net.params(), restored.params());
|
assertEquals(net.params(), restored.params());
|
||||||
} catch (IOException e){
|
} catch (IOException e){
|
||||||
//Should never happen
|
//Should never happen
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Also check the MultiLayerConfiguration is serializable (required by Spark etc)
|
//Also check the NeuralNetConfiguration is serializable (required by Spark etc)
|
||||||
MultiLayerConfiguration conf = net.getLayerWiseConfigurations();
|
NeuralNetConfiguration conf = net.getConfiguration();
|
||||||
serializeDeserializeJava(conf);
|
serializeDeserializeJava(conf);
|
||||||
|
|
||||||
return restored;
|
return restored;
|
||||||
|
@ -317,14 +317,14 @@ public class TestUtils {
|
||||||
for(Layer l : layers){
|
for(Layer l : layers){
|
||||||
//Don't use instanceof here - there are sub conv subclasses
|
//Don't use instanceof here - there are sub conv subclasses
|
||||||
if(l.getClass() == ConvolutionLayer.class || l instanceof SubsamplingLayer || l instanceof BatchNormalization || l instanceof LSTM){
|
if(l.getClass() == ConvolutionLayer.class || l instanceof SubsamplingLayer || l instanceof BatchNormalization || l instanceof LSTM){
|
||||||
Preconditions.checkNotNull(l.getHelper(), l.conf().getLayer().getLayerName());
|
Preconditions.checkNotNull(l.getHelper(), l.getLayerConfiguration().getLayerName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void assertHelpersAbsent(Layer[] layers) throws Exception {
|
public static void assertHelpersAbsent(Layer[] layers) throws Exception {
|
||||||
for(Layer l : layers){
|
for(Layer l : layers){
|
||||||
Preconditions.checkState(l.getHelper() == null, l.conf().getLayer().getLayerName());
|
Preconditions.checkState(l.getHelper() == null, l.getLayerConfiguration().getLayerName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,8 +31,8 @@ import org.deeplearning4j.datasets.iterator.impl.*;
|
||||||
import org.deeplearning4j.eval.Evaluation;
|
import org.deeplearning4j.eval.Evaluation;
|
||||||
import org.deeplearning4j.nn.api.OptimizationAlgorithm;
|
import org.deeplearning4j.nn.api.OptimizationAlgorithm;
|
||||||
import org.deeplearning4j.nn.conf.GradientNormalization;
|
import org.deeplearning4j.nn.conf.GradientNormalization;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration.NeuralNetConfigurationBuilder;
|
||||||
import org.deeplearning4j.nn.conf.inputs.InputType;
|
import org.deeplearning4j.nn.conf.inputs.InputType;
|
||||||
import org.deeplearning4j.nn.conf.layers.ConvolutionLayer;
|
import org.deeplearning4j.nn.conf.layers.ConvolutionLayer;
|
||||||
import org.deeplearning4j.nn.conf.layers.OutputLayer;
|
import org.deeplearning4j.nn.conf.layers.OutputLayer;
|
||||||
|
@ -168,9 +168,9 @@ public class DataSetIteratorTest extends BaseDL4JTest {
|
||||||
LFWDataSetIterator lfw = new LFWDataSetIterator(batchSize, numSamples,
|
LFWDataSetIterator lfw = new LFWDataSetIterator(batchSize, numSamples,
|
||||||
new int[] {numRows, numColumns, numChannels}, outputNum, false, true, 1.0, new Random(seed));
|
new int[] {numRows, numColumns, numChannels}, outputNum, false, true, 1.0, new Random(seed));
|
||||||
|
|
||||||
MultiLayerConfiguration.Builder builder = new NeuralNetConfiguration.Builder().seed(seed)
|
NeuralNetConfiguration.NeuralNetConfigurationBuilder builder = NeuralNetConfiguration.builder().seed(seed)
|
||||||
.gradientNormalization(GradientNormalization.RenormalizeL2PerLayer)
|
.gradientNormalization(GradientNormalization.RenormalizeL2PerLayer)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).list()
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.layer(0, new ConvolutionLayer.Builder(5, 5).nIn(numChannels).nOut(6)
|
.layer(0, new ConvolutionLayer.Builder(5, 5).nIn(numChannels).nOut(6)
|
||||||
.weightInit(WeightInit.XAVIER).activation(Activation.RELU).build())
|
.weightInit(WeightInit.XAVIER).activation(Activation.RELU).build())
|
||||||
.layer(1, new SubsamplingLayer.Builder(SubsamplingLayer.PoolingType.MAX, new int[] {2, 2})
|
.layer(1, new SubsamplingLayer.Builder(SubsamplingLayer.PoolingType.MAX, new int[] {2, 2})
|
||||||
|
@ -178,8 +178,7 @@ public class DataSetIteratorTest extends BaseDL4JTest {
|
||||||
.layer(2, new OutputLayer.Builder(LossFunctions.LossFunction.NEGATIVELOGLIKELIHOOD)
|
.layer(2, new OutputLayer.Builder(LossFunctions.LossFunction.NEGATIVELOGLIKELIHOOD)
|
||||||
.nOut(outputNum).weightInit(WeightInit.XAVIER).activation(Activation.SOFTMAX)
|
.nOut(outputNum).weightInit(WeightInit.XAVIER).activation(Activation.SOFTMAX)
|
||||||
.build())
|
.build())
|
||||||
.setInputType(InputType.convolutionalFlat(numRows, numColumns, numChannels))
|
.inputType(InputType.convolutionalFlat(numRows, numColumns, numChannels));
|
||||||
;
|
|
||||||
|
|
||||||
MultiLayerNetwork model = new MultiLayerNetwork(builder.build());
|
MultiLayerNetwork model = new MultiLayerNetwork(builder.build());
|
||||||
model.init();
|
model.init();
|
||||||
|
@ -229,9 +228,9 @@ public class DataSetIteratorTest extends BaseDL4JTest {
|
||||||
|
|
||||||
Cifar10DataSetIterator cifar = new Cifar10DataSetIterator(batchSize);
|
Cifar10DataSetIterator cifar = new Cifar10DataSetIterator(batchSize);
|
||||||
|
|
||||||
MultiLayerConfiguration.Builder builder = new NeuralNetConfiguration.Builder().seed(seed)
|
NeuralNetConfiguration.NeuralNetConfigurationBuilder builder = NeuralNetConfiguration.builder().seed(seed)
|
||||||
.gradientNormalization(GradientNormalization.RenormalizeL2PerLayer)
|
.gradientNormalization(GradientNormalization.RenormalizeL2PerLayer)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).list()
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.layer(0, new ConvolutionLayer.Builder(5, 5).nIn(channels).nOut(6).weightInit(WeightInit.XAVIER)
|
.layer(0, new ConvolutionLayer.Builder(5, 5).nIn(channels).nOut(6).weightInit(WeightInit.XAVIER)
|
||||||
.activation(Activation.RELU).build())
|
.activation(Activation.RELU).build())
|
||||||
.layer(1, new SubsamplingLayer.Builder(SubsamplingLayer.PoolingType.MAX, new int[] {2, 2})
|
.layer(1, new SubsamplingLayer.Builder(SubsamplingLayer.PoolingType.MAX, new int[] {2, 2})
|
||||||
|
@ -240,7 +239,7 @@ public class DataSetIteratorTest extends BaseDL4JTest {
|
||||||
.nOut(outputNum).weightInit(WeightInit.XAVIER).activation(Activation.SOFTMAX)
|
.nOut(outputNum).weightInit(WeightInit.XAVIER).activation(Activation.SOFTMAX)
|
||||||
.build())
|
.build())
|
||||||
|
|
||||||
.setInputType(InputType.convolutionalFlat(height, width, channels));
|
.inputType(InputType.convolutionalFlat(height, width, channels));
|
||||||
|
|
||||||
MultiLayerNetwork model = new MultiLayerNetwork(builder.build());
|
MultiLayerNetwork model = new MultiLayerNetwork(builder.build());
|
||||||
model.init();
|
model.init();
|
||||||
|
|
|
@ -38,10 +38,9 @@ import org.deeplearning4j.earlystopping.scorecalc.*;
|
||||||
import org.deeplearning4j.earlystopping.termination.*;
|
import org.deeplearning4j.earlystopping.termination.*;
|
||||||
import org.deeplearning4j.earlystopping.trainer.EarlyStoppingTrainer;
|
import org.deeplearning4j.earlystopping.trainer.EarlyStoppingTrainer;
|
||||||
import org.deeplearning4j.earlystopping.trainer.IEarlyStoppingTrainer;
|
import org.deeplearning4j.earlystopping.trainer.IEarlyStoppingTrainer;
|
||||||
import org.deeplearning4j.nn.api.Model;
|
import net.brutex.ai.dnn.api.IModel;
|
||||||
import org.deeplearning4j.nn.api.OptimizationAlgorithm;
|
import org.deeplearning4j.nn.api.OptimizationAlgorithm;
|
||||||
import org.deeplearning4j.nn.conf.GradientNormalization;
|
import org.deeplearning4j.nn.conf.GradientNormalization;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.layers.*;
|
import org.deeplearning4j.nn.conf.layers.*;
|
||||||
import org.deeplearning4j.nn.conf.layers.variational.BernoulliReconstructionDistribution;
|
import org.deeplearning4j.nn.conf.layers.variational.BernoulliReconstructionDistribution;
|
||||||
|
@ -133,9 +132,9 @@ public class TestEarlyStopping extends BaseDL4JTest {
|
||||||
String msg = i + " - " + sc.getClass().getSimpleName();
|
String msg = i + " - " + sc.getClass().getSimpleName();
|
||||||
log.info("Starting test - {}", msg);
|
log.info("Starting test - {}", msg);
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.seed(12345)
|
.seed(12345)
|
||||||
.updater(new Sgd(0.5)).weightInit(WeightInit.XAVIER).list()
|
.updater(new Sgd(0.5)).weightInit(WeightInit.XAVIER)
|
||||||
.layer(new DenseLayer.Builder().nIn(4).nOut(4).activation(Activation.TANH).build())
|
.layer(new DenseLayer.Builder().nIn(4).nOut(4).activation(Activation.TANH).build())
|
||||||
.layer(new OutputLayer.Builder().nIn(4).nOut(3)
|
.layer(new OutputLayer.Builder().nIn(4).nOut(3)
|
||||||
.activation(Activation.SOFTMAX)
|
.activation(Activation.SOFTMAX)
|
||||||
|
@ -219,9 +218,9 @@ public class TestEarlyStopping extends BaseDL4JTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEarlyStoppingEveryNEpoch() {
|
public void testEarlyStoppingEveryNEpoch() {
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.updater(new Sgd(0.01)).weightInit(WeightInit.XAVIER).list()
|
.updater(new Sgd(0.01)).weightInit(WeightInit.XAVIER)
|
||||||
.layer(0, new OutputLayer.Builder().nIn(4).nOut(3)
|
.layer(0, new OutputLayer.Builder().nIn(4).nOut(3)
|
||||||
.activation(Activation.SOFTMAX)
|
.activation(Activation.SOFTMAX)
|
||||||
.lossFunction(LossFunctions.LossFunction.MCXENT).build())
|
.lossFunction(LossFunctions.LossFunction.MCXENT).build())
|
||||||
|
@ -248,9 +247,9 @@ public class TestEarlyStopping extends BaseDL4JTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEarlyStoppingIrisMultiEpoch() {
|
public void testEarlyStoppingIrisMultiEpoch() {
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.updater(new Sgd(0.001)).weightInit(WeightInit.XAVIER).list()
|
.updater(new Sgd(0.001)).weightInit(WeightInit.XAVIER)
|
||||||
.layer(0, new OutputLayer.Builder().nIn(4).nOut(3)
|
.layer(0, new OutputLayer.Builder().nIn(4).nOut(3)
|
||||||
.activation(Activation.SOFTMAX)
|
.activation(Activation.SOFTMAX)
|
||||||
.lossFunction(LossFunctions.LossFunction.MCXENT).build())
|
.lossFunction(LossFunctions.LossFunction.MCXENT).build())
|
||||||
|
@ -297,10 +296,10 @@ public class TestEarlyStopping extends BaseDL4JTest {
|
||||||
//Test poor tuning (high LR): should terminate on MaxScoreIterationTerminationCondition
|
//Test poor tuning (high LR): should terminate on MaxScoreIterationTerminationCondition
|
||||||
|
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345)
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().seed(12345)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.updater(new Sgd(5.0)) //Intentionally huge LR
|
.updater(new Sgd(5.0)) //Intentionally huge LR
|
||||||
.weightInit(WeightInit.XAVIER).list()
|
.weightInit(WeightInit.XAVIER)
|
||||||
.layer(0, new OutputLayer.Builder().nIn(4).nOut(3).activation(Activation.SOFTMAX)
|
.layer(0, new OutputLayer.Builder().nIn(4).nOut(3).activation(Activation.SOFTMAX)
|
||||||
.lossFunction(LossFunctions.LossFunction.MCXENT).build())
|
.lossFunction(LossFunctions.LossFunction.MCXENT).build())
|
||||||
.build();
|
.build();
|
||||||
|
@ -336,9 +335,9 @@ public class TestEarlyStopping extends BaseDL4JTest {
|
||||||
//test termination after max time
|
//test termination after max time
|
||||||
|
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345)
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().seed(12345)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.updater(new Sgd(1e-6)).weightInit(WeightInit.XAVIER).list()
|
.updater(new Sgd(1e-6)).weightInit(WeightInit.XAVIER)
|
||||||
.layer(0, new OutputLayer.Builder().nIn(4).nOut(3)
|
.layer(0, new OutputLayer.Builder().nIn(4).nOut(3)
|
||||||
.activation(Activation.SOFTMAX)
|
.activation(Activation.SOFTMAX)
|
||||||
.lossFunction(LossFunctions.LossFunction.MCXENT).build())
|
.lossFunction(LossFunctions.LossFunction.MCXENT).build())
|
||||||
|
@ -379,9 +378,9 @@ public class TestEarlyStopping extends BaseDL4JTest {
|
||||||
//Simulate this by setting LR = 0.0
|
//Simulate this by setting LR = 0.0
|
||||||
|
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345)
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().seed(12345)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.updater(new Sgd(0.0)).weightInit(WeightInit.XAVIER).list()
|
.updater(new Sgd(0.0)).weightInit(WeightInit.XAVIER)
|
||||||
.layer(0, new OutputLayer.Builder().nIn(4).nOut(3)
|
.layer(0, new OutputLayer.Builder().nIn(4).nOut(3)
|
||||||
.activation(Activation.SOFTMAX)
|
.activation(Activation.SOFTMAX)
|
||||||
.lossFunction(LossFunctions.LossFunction.MCXENT).build())
|
.lossFunction(LossFunctions.LossFunction.MCXENT).build())
|
||||||
|
@ -419,9 +418,9 @@ public class TestEarlyStopping extends BaseDL4JTest {
|
||||||
//Simulate this by setting LR = 0.0
|
//Simulate this by setting LR = 0.0
|
||||||
Random rng = new Random(123);
|
Random rng = new Random(123);
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().seed(123)
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().seed(123)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.updater(new Nesterovs(0.0,0.9)).list()
|
.updater(new Nesterovs(0.0,0.9))
|
||||||
.layer(0, new DenseLayer.Builder().nIn(1).nOut(20)
|
.layer(0, new DenseLayer.Builder().nIn(1).nOut(20)
|
||||||
.weightInit(WeightInit.XAVIER).activation(
|
.weightInit(WeightInit.XAVIER).activation(
|
||||||
Activation.TANH)
|
Activation.TANH)
|
||||||
|
@ -466,9 +465,9 @@ public class TestEarlyStopping extends BaseDL4JTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEarlyStoppingGetBestModel() {
|
public void testEarlyStoppingGetBestModel() {
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.updater(new Sgd(0.001)).weightInit(WeightInit.XAVIER).list()
|
.updater(new Sgd(0.001)).weightInit(WeightInit.XAVIER)
|
||||||
.layer(0, new OutputLayer.Builder().nIn(4).nOut(3)
|
.layer(0, new OutputLayer.Builder().nIn(4).nOut(3)
|
||||||
.activation(Activation.SOFTMAX)
|
.activation(Activation.SOFTMAX)
|
||||||
.lossFunction(LossFunctions.LossFunction.MCXENT).build())
|
.lossFunction(LossFunctions.LossFunction.MCXENT).build())
|
||||||
|
@ -496,17 +495,17 @@ public class TestEarlyStopping extends BaseDL4JTest {
|
||||||
MultiLayerNetwork mln = result.getBestModel();
|
MultiLayerNetwork mln = result.getBestModel();
|
||||||
|
|
||||||
assertEquals(net.getnLayers(), mln.getnLayers());
|
assertEquals(net.getnLayers(), mln.getnLayers());
|
||||||
assertEquals(net.conf().getOptimizationAlgo(), mln.conf().getOptimizationAlgo());
|
assertEquals(net.getNetConfiguration().getOptimizationAlgo(), mln.getNetConfiguration().getOptimizationAlgo());
|
||||||
BaseLayer bl = (BaseLayer) net.conf().getLayer();
|
BaseLayer bl = (BaseLayer) net.getLayerConfiguration();
|
||||||
assertEquals(bl.getActivationFn().toString(), ((BaseLayer) mln.conf().getLayer()).getActivationFn().toString());
|
assertEquals(bl.getActivationFn().toString(), ((BaseLayer) mln.getLayerConfiguration()).getActivationFn().toString());
|
||||||
assertEquals(bl.getIUpdater(), ((BaseLayer) mln.conf().getLayer()).getIUpdater());
|
assertEquals(bl.getIUpdater(), ((BaseLayer) mln.getLayerConfiguration()).getIUpdater());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListeners() {
|
public void testListeners() {
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.updater(new Sgd(0.001)).weightInit(WeightInit.XAVIER).list()
|
.updater(new Sgd(0.001)).weightInit(WeightInit.XAVIER)
|
||||||
.layer(0, new OutputLayer.Builder().nIn(4).nOut(3)
|
.layer(0, new OutputLayer.Builder().nIn(4).nOut(3)
|
||||||
.activation(Activation.SOFTMAX)
|
.activation(Activation.SOFTMAX)
|
||||||
.lossFunction(LossFunctions.LossFunction.MCXENT).build())
|
.lossFunction(LossFunctions.LossFunction.MCXENT).build())
|
||||||
|
@ -569,8 +568,8 @@ public class TestEarlyStopping extends BaseDL4JTest {
|
||||||
Metric.MAE}) {
|
Metric.MAE}) {
|
||||||
log.info("Metric: " + metric);
|
log.info("Metric: " + metric);
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.list()
|
|
||||||
.layer(new DenseLayer.Builder().nIn(784).nOut(32).build())
|
.layer(new DenseLayer.Builder().nIn(784).nOut(32).build())
|
||||||
.layer(new OutputLayer.Builder().nIn(32).nOut(784).activation(Activation.SIGMOID).lossFunction(LossFunctions.LossFunction.MSE).build())
|
.layer(new OutputLayer.Builder().nIn(32).nOut(784).activation(Activation.SIGMOID).lossFunction(LossFunctions.LossFunction.MSE).build())
|
||||||
.build();
|
.build();
|
||||||
|
@ -612,8 +611,8 @@ public class TestEarlyStopping extends BaseDL4JTest {
|
||||||
Metric.MAE}) {
|
Metric.MAE}) {
|
||||||
log.info("Metric: " + metric);
|
log.info("Metric: " + metric);
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.list()
|
|
||||||
.layer(new AutoEncoder.Builder().nIn(784).nOut(32).build())
|
.layer(new AutoEncoder.Builder().nIn(784).nOut(32).build())
|
||||||
|
|
||||||
.build();
|
.build();
|
||||||
|
@ -655,8 +654,8 @@ public class TestEarlyStopping extends BaseDL4JTest {
|
||||||
Metric.MAE}) {
|
Metric.MAE}) {
|
||||||
log.info("Metric: " + metric);
|
log.info("Metric: " + metric);
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.list()
|
|
||||||
.layer(new VariationalAutoencoder.Builder()
|
.layer(new VariationalAutoencoder.Builder()
|
||||||
.nIn(784).nOut(32)
|
.nIn(784).nOut(32)
|
||||||
.encoderLayerSizes(64)
|
.encoderLayerSizes(64)
|
||||||
|
@ -700,8 +699,8 @@ public class TestEarlyStopping extends BaseDL4JTest {
|
||||||
|
|
||||||
for(boolean logProb : new boolean[]{false, true}) {
|
for(boolean logProb : new boolean[]{false, true}) {
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.list()
|
|
||||||
.layer(new VariationalAutoencoder.Builder()
|
.layer(new VariationalAutoencoder.Builder()
|
||||||
.nIn(784).nOut(32)
|
.nIn(784).nOut(32)
|
||||||
.encoderLayerSizes(64)
|
.encoderLayerSizes(64)
|
||||||
|
@ -747,8 +746,8 @@ public class TestEarlyStopping extends BaseDL4JTest {
|
||||||
for(Evaluation.Metric metric : Evaluation.Metric.values()) {
|
for(Evaluation.Metric metric : Evaluation.Metric.values()) {
|
||||||
log.info("Metric: " + metric);
|
log.info("Metric: " + metric);
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.list()
|
|
||||||
.layer(new DenseLayer.Builder().nIn(784).nOut(32).build())
|
.layer(new DenseLayer.Builder().nIn(784).nOut(32).build())
|
||||||
.layer(new OutputLayer.Builder().nIn(32).nOut(10).activation(Activation.SOFTMAX).build())
|
.layer(new OutputLayer.Builder().nIn(32).nOut(10).activation(Activation.SOFTMAX).build())
|
||||||
.build();
|
.build();
|
||||||
|
@ -784,8 +783,8 @@ public class TestEarlyStopping extends BaseDL4JTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEarlyStoppingListeners() {
|
public void testEarlyStoppingListeners() {
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.updater(new Sgd(0.001)).weightInit(WeightInit.XAVIER).list()
|
.updater(new Sgd(0.001)).weightInit(WeightInit.XAVIER)
|
||||||
.layer(0, new OutputLayer.Builder().nIn(4).nOut(3)
|
.layer(0, new OutputLayer.Builder().nIn(4).nOut(3)
|
||||||
.activation(Activation.SOFTMAX)
|
.activation(Activation.SOFTMAX)
|
||||||
.lossFunction(LossFunctions.LossFunction.MCXENT).build())
|
.lossFunction(LossFunctions.LossFunction.MCXENT).build())
|
||||||
|
@ -827,19 +826,19 @@ public class TestEarlyStopping extends BaseDL4JTest {
|
||||||
private int maxEpochEnd = -1;
|
private int maxEpochEnd = -1;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEpochStart(Model model){
|
public void onEpochStart(IModel model){
|
||||||
countEpochStart++;
|
countEpochStart++;
|
||||||
maxEpochStart = Math.max(maxEpochStart, BaseOptimizer.getEpochCount(model));
|
maxEpochStart = Math.max(maxEpochStart, BaseOptimizer.getEpochCount(model));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEpochEnd(Model model){
|
public void onEpochEnd(IModel model){
|
||||||
countEpochEnd++;
|
countEpochEnd++;
|
||||||
maxEpochEnd = Math.max(maxEpochEnd, BaseOptimizer.getEpochCount(model));
|
maxEpochEnd = Math.max(maxEpochEnd, BaseOptimizer.getEpochCount(model));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void iterationDone(Model model, int iteration, int epoch){
|
public void iterationDone(IModel model, int iteration, int epoch){
|
||||||
iterCount++;
|
iterCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -859,7 +858,7 @@ public class TestEarlyStopping extends BaseDL4JTest {
|
||||||
DataSetIterator test = new SingletonDataSetIterator(ds);
|
DataSetIterator test = new SingletonDataSetIterator(ds);
|
||||||
|
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.seed(123)
|
.seed(123)
|
||||||
.weightInit(WeightInit.XAVIER)
|
.weightInit(WeightInit.XAVIER)
|
||||||
.updater(new Adam(0.1))
|
.updater(new Adam(0.1))
|
||||||
|
@ -868,7 +867,7 @@ public class TestEarlyStopping extends BaseDL4JTest {
|
||||||
.gradientNormalization(GradientNormalization
|
.gradientNormalization(GradientNormalization
|
||||||
.ClipElementWiseAbsoluteValue)
|
.ClipElementWiseAbsoluteValue)
|
||||||
.gradientNormalizationThreshold(1.0)
|
.gradientNormalizationThreshold(1.0)
|
||||||
.list()
|
|
||||||
.layer(0, new LSTM.Builder()
|
.layer(0, new LSTM.Builder()
|
||||||
.nIn(10)
|
.nIn(10)
|
||||||
.nOut(10)
|
.nOut(10)
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class TestEarlyStoppingCompGraph extends BaseDL4JTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEarlyStoppingIris() {
|
public void testEarlyStoppingIris() {
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder()
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.updater(new Sgd(0.001)).weightInit(WeightInit.XAVIER).graphBuilder().addInputs("in")
|
.updater(new Sgd(0.001)).weightInit(WeightInit.XAVIER).graphBuilder().addInputs("in")
|
||||||
.addLayer("0", new OutputLayer.Builder().nIn(4).nOut(3)
|
.addLayer("0", new OutputLayer.Builder().nIn(4).nOut(3)
|
||||||
|
@ -120,7 +120,7 @@ public class TestEarlyStoppingCompGraph extends BaseDL4JTest {
|
||||||
//Test poor tuning (high LR): should terminate on MaxScoreIterationTerminationCondition
|
//Test poor tuning (high LR): should terminate on MaxScoreIterationTerminationCondition
|
||||||
|
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345)
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder().seed(12345)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.updater(new Sgd(5.0)) //Intentionally huge LR
|
.updater(new Sgd(5.0)) //Intentionally huge LR
|
||||||
.weightInit(WeightInit.XAVIER).graphBuilder().addInputs("in")
|
.weightInit(WeightInit.XAVIER).graphBuilder().addInputs("in")
|
||||||
|
@ -156,7 +156,7 @@ public class TestEarlyStoppingCompGraph extends BaseDL4JTest {
|
||||||
//test termination after max time
|
//test termination after max time
|
||||||
|
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345)
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder().seed(12345)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.updater(new Sgd(1e-6)).weightInit(WeightInit.XAVIER).graphBuilder()
|
.updater(new Sgd(1e-6)).weightInit(WeightInit.XAVIER).graphBuilder()
|
||||||
.addInputs("in")
|
.addInputs("in")
|
||||||
|
@ -198,7 +198,7 @@ public class TestEarlyStoppingCompGraph extends BaseDL4JTest {
|
||||||
//Simulate this by setting LR = 0.0
|
//Simulate this by setting LR = 0.0
|
||||||
|
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345)
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder().seed(12345)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.updater(new Sgd(0.0)).weightInit(WeightInit.XAVIER).graphBuilder()
|
.updater(new Sgd(0.0)).weightInit(WeightInit.XAVIER).graphBuilder()
|
||||||
.addInputs("in")
|
.addInputs("in")
|
||||||
|
@ -233,7 +233,7 @@ public class TestEarlyStoppingCompGraph extends BaseDL4JTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListeners() {
|
public void testListeners() {
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder()
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.updater(new Sgd(0.001)).weightInit(WeightInit.XAVIER).graphBuilder().addInputs("in")
|
.updater(new Sgd(0.001)).weightInit(WeightInit.XAVIER).graphBuilder().addInputs("in")
|
||||||
.addLayer("0", new OutputLayer.Builder().nIn(4).nOut(3)
|
.addLayer("0", new OutputLayer.Builder().nIn(4).nOut(3)
|
||||||
|
@ -297,7 +297,7 @@ public class TestEarlyStoppingCompGraph extends BaseDL4JTest {
|
||||||
Metric.MAE}) {
|
Metric.MAE}) {
|
||||||
log.info("Metric: " + metric);
|
log.info("Metric: " + metric);
|
||||||
|
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder()
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.graphBuilder()
|
.graphBuilder()
|
||||||
.addInputs("in")
|
.addInputs("in")
|
||||||
.layer("0", new DenseLayer.Builder().nIn(784).nOut(32).build(), "in")
|
.layer("0", new DenseLayer.Builder().nIn(784).nOut(32).build(), "in")
|
||||||
|
@ -343,7 +343,7 @@ public class TestEarlyStoppingCompGraph extends BaseDL4JTest {
|
||||||
Metric.MAE}) {
|
Metric.MAE}) {
|
||||||
log.info("Metric: " + metric);
|
log.info("Metric: " + metric);
|
||||||
|
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder()
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.graphBuilder()
|
.graphBuilder()
|
||||||
.addInputs("in")
|
.addInputs("in")
|
||||||
.layer("0", new AutoEncoder.Builder().nIn(784).nOut(32).build(), "in")
|
.layer("0", new AutoEncoder.Builder().nIn(784).nOut(32).build(), "in")
|
||||||
|
@ -388,7 +388,7 @@ public class TestEarlyStoppingCompGraph extends BaseDL4JTest {
|
||||||
Metric.MAE}) {
|
Metric.MAE}) {
|
||||||
log.info("Metric: " + metric);
|
log.info("Metric: " + metric);
|
||||||
|
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder()
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.graphBuilder()
|
.graphBuilder()
|
||||||
.addInputs("in")
|
.addInputs("in")
|
||||||
.layer("0", new VariationalAutoencoder.Builder()
|
.layer("0", new VariationalAutoencoder.Builder()
|
||||||
|
@ -435,7 +435,7 @@ public class TestEarlyStoppingCompGraph extends BaseDL4JTest {
|
||||||
|
|
||||||
for(boolean logProb : new boolean[]{false, true}) {
|
for(boolean logProb : new boolean[]{false, true}) {
|
||||||
|
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder()
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.updater(new Adam(1e-5))
|
.updater(new Adam(1e-5))
|
||||||
.graphBuilder()
|
.graphBuilder()
|
||||||
.addInputs("in")
|
.addInputs("in")
|
||||||
|
@ -486,7 +486,7 @@ public class TestEarlyStoppingCompGraph extends BaseDL4JTest {
|
||||||
for(Evaluation.Metric metric : Evaluation.Metric.values()) {
|
for(Evaluation.Metric metric : Evaluation.Metric.values()) {
|
||||||
log.info("Metric: " + metric);
|
log.info("Metric: " + metric);
|
||||||
|
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder()
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.graphBuilder()
|
.graphBuilder()
|
||||||
.addInputs("in")
|
.addInputs("in")
|
||||||
.layer("0", new DenseLayer.Builder().nIn(784).nOut(32).build(), "in")
|
.layer("0", new DenseLayer.Builder().nIn(784).nOut(32).build(), "in")
|
||||||
|
@ -526,7 +526,7 @@ public class TestEarlyStoppingCompGraph extends BaseDL4JTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEarlyStoppingListenersCG() {
|
public void testEarlyStoppingListenersCG() {
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder()
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.updater(new Sgd(0.001)).weightInit(WeightInit.XAVIER)
|
.updater(new Sgd(0.001)).weightInit(WeightInit.XAVIER)
|
||||||
.graphBuilder()
|
.graphBuilder()
|
||||||
.addInputs("in")
|
.addInputs("in")
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class EvalTest extends BaseDL4JTest {
|
||||||
public void testIris() {
|
public void testIris() {
|
||||||
|
|
||||||
// Network config
|
// Network config
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
|
|
||||||
.optimizationAlgo(OptimizationAlgorithm.LINE_GRADIENT_DESCENT).seed(42)
|
.optimizationAlgo(OptimizationAlgorithm.LINE_GRADIENT_DESCENT).seed(42)
|
||||||
.updater(new Sgd(1e-6)).list()
|
.updater(new Sgd(1e-6)).list()
|
||||||
|
@ -177,7 +177,7 @@ public class EvalTest extends BaseDL4JTest {
|
||||||
rrdsi.reset();
|
rrdsi.reset();
|
||||||
|
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345)
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().seed(12345)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).updater(new Sgd(0.1))
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).updater(new Sgd(0.1))
|
||||||
.list()
|
.list()
|
||||||
.layer(0, new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
.layer(0, new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
||||||
|
@ -295,7 +295,7 @@ public class EvalTest extends BaseDL4JTest {
|
||||||
int tbpttLength = 10;
|
int tbpttLength = 10;
|
||||||
int tsLength = 5 * tbpttLength + tbpttLength / 2;
|
int tsLength = 5 * tbpttLength + tbpttLength / 2;
|
||||||
|
|
||||||
MultiLayerConfiguration conf1 = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf1 = NeuralNetConfiguration.builder()
|
||||||
.seed(12345)
|
.seed(12345)
|
||||||
.trainingWorkspaceMode(ws)
|
.trainingWorkspaceMode(ws)
|
||||||
.inferenceWorkspaceMode(ws)
|
.inferenceWorkspaceMode(ws)
|
||||||
|
@ -306,7 +306,7 @@ public class EvalTest extends BaseDL4JTest {
|
||||||
.build())
|
.build())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
MultiLayerConfiguration conf2 = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf2 = NeuralNetConfiguration.builder()
|
||||||
.seed(12345)
|
.seed(12345)
|
||||||
.trainingWorkspaceMode(ws)
|
.trainingWorkspaceMode(ws)
|
||||||
.inferenceWorkspaceMode(ws)
|
.inferenceWorkspaceMode(ws)
|
||||||
|
@ -314,7 +314,7 @@ public class EvalTest extends BaseDL4JTest {
|
||||||
.layer(new LSTM.Builder().nIn(nIn).nOut(layerSize).build())
|
.layer(new LSTM.Builder().nIn(nIn).nOut(layerSize).build())
|
||||||
.layer(new RnnOutputLayer.Builder().nIn(layerSize).nOut(nOut)
|
.layer(new RnnOutputLayer.Builder().nIn(layerSize).nOut(nOut)
|
||||||
.activation(Activation.SOFTMAX).build())
|
.activation(Activation.SOFTMAX).build())
|
||||||
.tBPTTLength(10)
|
.tbpttFwdLength(10).tbpttBackLength(10)
|
||||||
.backpropType(BackpropType.TruncatedBPTT)
|
.backpropType(BackpropType.TruncatedBPTT)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -371,7 +371,7 @@ public class EvalTest extends BaseDL4JTest {
|
||||||
int tbpttLength = 10;
|
int tbpttLength = 10;
|
||||||
int tsLength = 5 * tbpttLength + tbpttLength / 2;
|
int tsLength = 5 * tbpttLength + tbpttLength / 2;
|
||||||
|
|
||||||
ComputationGraphConfiguration conf1 = new NeuralNetConfiguration.Builder()
|
ComputationGraphConfiguration conf1 = NeuralNetConfiguration.builder()
|
||||||
.seed(12345)
|
.seed(12345)
|
||||||
.trainingWorkspaceMode(ws)
|
.trainingWorkspaceMode(ws)
|
||||||
.inferenceWorkspaceMode(ws)
|
.inferenceWorkspaceMode(ws)
|
||||||
|
@ -384,7 +384,7 @@ public class EvalTest extends BaseDL4JTest {
|
||||||
.setOutputs("1")
|
.setOutputs("1")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
ComputationGraphConfiguration conf2 = new NeuralNetConfiguration.Builder()
|
ComputationGraphConfiguration conf2 = NeuralNetConfiguration.builder()
|
||||||
.seed(12345)
|
.seed(12345)
|
||||||
.trainingWorkspaceMode(ws)
|
.trainingWorkspaceMode(ws)
|
||||||
.inferenceWorkspaceMode(ws)
|
.inferenceWorkspaceMode(ws)
|
||||||
|
@ -455,12 +455,12 @@ public class EvalTest extends BaseDL4JTest {
|
||||||
DataSetIterator testData = new SequenceRecordReaderDataSetIterator(fsr, lsr, 1, -1, true,
|
DataSetIterator testData = new SequenceRecordReaderDataSetIterator(fsr, lsr, 1, -1, true,
|
||||||
SequenceRecordReaderDataSetIterator.AlignmentMode.ALIGN_END);
|
SequenceRecordReaderDataSetIterator.AlignmentMode.ALIGN_END);
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().seed(123)
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().seed(123)
|
||||||
.list()
|
.list()
|
||||||
.layer(0, new LSTM.Builder().activation(Activation.TANH).nIn(3).nOut(3).build())
|
.layer(0, new LSTM.Builder().activation(Activation.TANH).nIn(3).nOut(3).build())
|
||||||
.layer(1, new RnnOutputLayer.Builder().activation(Activation.SIGMOID).lossFunction(LossFunctions.LossFunction.XENT)
|
.layer(1, new RnnOutputLayer.Builder().activation(Activation.SIGMOID).lossFunction(LossFunctions.LossFunction.XENT)
|
||||||
.nIn(3).nOut(1).build())
|
.nIn(3).nOut(1).build())
|
||||||
.backpropType(BackpropType.TruncatedBPTT).tBPTTForwardLength(10).tBPTTBackwardLength(10)
|
.backpropType(BackpropType.TruncatedBPTT).tbpttFwdLength(10).tbpttBackLength(10)
|
||||||
.build();
|
.build();
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
net.init();
|
net.init();
|
||||||
|
@ -473,7 +473,7 @@ public class EvalTest extends BaseDL4JTest {
|
||||||
//Sanity check: https://github.com/eclipse/deeplearning4j/issues/5351
|
//Sanity check: https://github.com/eclipse/deeplearning4j/issues/5351
|
||||||
|
|
||||||
// Network config
|
// Network config
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
|
|
||||||
.optimizationAlgo(OptimizationAlgorithm.LINE_GRADIENT_DESCENT).seed(42)
|
.optimizationAlgo(OptimizationAlgorithm.LINE_GRADIENT_DESCENT).seed(42)
|
||||||
.updater(new Sgd(1e-6)).list()
|
.updater(new Sgd(1e-6)).list()
|
||||||
|
@ -503,7 +503,7 @@ public class EvalTest extends BaseDL4JTest {
|
||||||
public void testMultiOutputEvalSimple(){
|
public void testMultiOutputEvalSimple(){
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
|
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder()
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.seed(12345)
|
.seed(12345)
|
||||||
.graphBuilder()
|
.graphBuilder()
|
||||||
.addInputs("in")
|
.addInputs("in")
|
||||||
|
@ -538,7 +538,7 @@ public class EvalTest extends BaseDL4JTest {
|
||||||
public void testMultiOutputEvalCG(){
|
public void testMultiOutputEvalCG(){
|
||||||
//Simple sanity check on evaluation
|
//Simple sanity check on evaluation
|
||||||
|
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder()
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.graphBuilder()
|
.graphBuilder()
|
||||||
.addInputs("in")
|
.addInputs("in")
|
||||||
.layer("0", new EmbeddingSequenceLayer.Builder().nIn(10).nOut(10).build(), "in")
|
.layer("0", new EmbeddingSequenceLayer.Builder().nIn(10).nOut(10).build(), "in")
|
||||||
|
@ -566,7 +566,7 @@ public class EvalTest extends BaseDL4JTest {
|
||||||
@Test
|
@Test
|
||||||
public void testInvalidEvaluation(){
|
public void testInvalidEvaluation(){
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
|
|
||||||
.list()
|
.list()
|
||||||
.layer(new DenseLayer.Builder().nIn(4).nOut(10).build())
|
.layer(new DenseLayer.Builder().nIn(4).nOut(10).build())
|
||||||
|
@ -622,7 +622,7 @@ public class EvalTest extends BaseDL4JTest {
|
||||||
|
|
||||||
|
|
||||||
//Disable validation, and check same thing:
|
//Disable validation, and check same thing:
|
||||||
net.getLayerWiseConfigurations().setValidateOutputLayerConfig(false);
|
net.getConfiguration().setValidateOutputLayerConfig(false);
|
||||||
net.evaluate(iter);
|
net.evaluate(iter);
|
||||||
net.evaluateROCMultiClass(iter, 0);
|
net.evaluateROCMultiClass(iter, 0);
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@ package org.deeplearning4j.eval;
|
||||||
import org.deeplearning4j.BaseDL4JTest;
|
import org.deeplearning4j.BaseDL4JTest;
|
||||||
import org.deeplearning4j.datasets.iterator.impl.IrisDataSetIterator;
|
import org.deeplearning4j.datasets.iterator.impl.IrisDataSetIterator;
|
||||||
import org.deeplearning4j.core.evaluation.EvaluationTools;
|
import org.deeplearning4j.core.evaluation.EvaluationTools;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.layers.DenseLayer;
|
import org.deeplearning4j.nn.conf.layers.DenseLayer;
|
||||||
import org.deeplearning4j.nn.conf.layers.OutputLayer;
|
import org.deeplearning4j.nn.conf.layers.OutputLayer;
|
||||||
|
@ -48,7 +47,7 @@ public class EvaluationToolsTests extends BaseDL4JTest {
|
||||||
|
|
||||||
DataSetIterator iter = new IrisDataSetIterator(150, 150);
|
DataSetIterator iter = new IrisDataSetIterator(150, 150);
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().weightInit(WeightInit.XAVIER).list()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().weightInit(WeightInit.XAVIER).list()
|
||||||
.layer(0, new DenseLayer.Builder().nIn(4).nOut(4).activation(Activation.TANH).build()).layer(1,
|
.layer(0, new DenseLayer.Builder().nIn(4).nOut(4).activation(Activation.TANH).build()).layer(1,
|
||||||
new OutputLayer.Builder().nIn(4).nOut(2).activation(Activation.SOFTMAX)
|
new OutputLayer.Builder().nIn(4).nOut(2).activation(Activation.SOFTMAX)
|
||||||
.lossFunction(LossFunctions.LossFunction.MCXENT).build())
|
.lossFunction(LossFunctions.LossFunction.MCXENT).build())
|
||||||
|
@ -90,7 +89,7 @@ public class EvaluationToolsTests extends BaseDL4JTest {
|
||||||
public void testRocMultiToHtml() throws Exception {
|
public void testRocMultiToHtml() throws Exception {
|
||||||
DataSetIterator iter = new IrisDataSetIterator(150, 150);
|
DataSetIterator iter = new IrisDataSetIterator(150, 150);
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().weightInit(WeightInit.XAVIER).list()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().weightInit(WeightInit.XAVIER).list()
|
||||||
.layer(0, new DenseLayer.Builder().nIn(4).nOut(4).activation(Activation.TANH).build()).layer(1,
|
.layer(0, new DenseLayer.Builder().nIn(4).nOut(4).activation(Activation.TANH).build()).layer(1,
|
||||||
new OutputLayer.Builder().nIn(4).nOut(3).activation(Activation.SOFTMAX)
|
new OutputLayer.Builder().nIn(4).nOut(3).activation(Activation.SOFTMAX)
|
||||||
.lossFunction(LossFunctions.LossFunction.MCXENT).build())
|
.lossFunction(LossFunctions.LossFunction.MCXENT).build())
|
||||||
|
|
|
@ -22,23 +22,19 @@ package org.deeplearning4j.eval;
|
||||||
|
|
||||||
import org.deeplearning4j.BaseDL4JTest;
|
import org.deeplearning4j.BaseDL4JTest;
|
||||||
import org.deeplearning4j.datasets.iterator.impl.IrisDataSetIterator;
|
import org.deeplearning4j.datasets.iterator.impl.IrisDataSetIterator;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.layers.DenseLayer;
|
import org.deeplearning4j.nn.conf.layers.DenseLayer;
|
||||||
import org.deeplearning4j.nn.conf.layers.OutputLayer;
|
import org.deeplearning4j.nn.conf.layers.OutputLayer;
|
||||||
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
||||||
import org.deeplearning4j.nn.weights.WeightInit;
|
import org.deeplearning4j.nn.weights.WeightInit;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.nd4j.evaluation.curves.PrecisionRecallCurve;
|
|
||||||
import org.nd4j.evaluation.curves.RocCurve;
|
import org.nd4j.evaluation.curves.RocCurve;
|
||||||
import org.nd4j.linalg.activations.Activation;
|
import org.nd4j.linalg.activations.Activation;
|
||||||
import org.nd4j.linalg.api.ndarray.INDArray;
|
import org.nd4j.linalg.api.ndarray.INDArray;
|
||||||
import org.nd4j.linalg.api.ops.random.impl.BernoulliDistribution;
|
|
||||||
import org.nd4j.linalg.dataset.api.DataSet;
|
import org.nd4j.linalg.dataset.api.DataSet;
|
||||||
import org.nd4j.linalg.dataset.api.iterator.DataSetIterator;
|
import org.nd4j.linalg.dataset.api.iterator.DataSetIterator;
|
||||||
import org.nd4j.linalg.dataset.api.preprocessor.NormalizerStandardize;
|
import org.nd4j.linalg.dataset.api.preprocessor.NormalizerStandardize;
|
||||||
import org.nd4j.linalg.factory.Nd4j;
|
import org.nd4j.linalg.factory.Nd4j;
|
||||||
import org.nd4j.linalg.indexing.NDArrayIndex;
|
|
||||||
import org.nd4j.linalg.lossfunctions.LossFunctions;
|
import org.nd4j.linalg.lossfunctions.LossFunctions;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
@ -86,7 +82,7 @@ public class ROCTest extends BaseDL4JTest {
|
||||||
DataSetIterator iter = new IrisDataSetIterator(150, 150);
|
DataSetIterator iter = new IrisDataSetIterator(150, 150);
|
||||||
|
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().weightInit(WeightInit.XAVIER).seed(12345)
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().weightInit(WeightInit.XAVIER).seed(12345)
|
||||||
.list()
|
.list()
|
||||||
.layer(0, new DenseLayer.Builder().nIn(4).nOut(4).activation(Activation.TANH).build()).layer(1,
|
.layer(0, new DenseLayer.Builder().nIn(4).nOut(4).activation(Activation.TANH).build()).layer(1,
|
||||||
new OutputLayer.Builder().nIn(4).nOut(3).activation(Activation.SOFTMAX)
|
new OutputLayer.Builder().nIn(4).nOut(3).activation(Activation.SOFTMAX)
|
||||||
|
|
|
@ -23,7 +23,6 @@ package org.deeplearning4j.eval;
|
||||||
import org.deeplearning4j.BaseDL4JTest;
|
import org.deeplearning4j.BaseDL4JTest;
|
||||||
import org.deeplearning4j.datasets.iterator.ExistingDataSetIterator;
|
import org.deeplearning4j.datasets.iterator.ExistingDataSetIterator;
|
||||||
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.layers.OutputLayer;
|
import org.deeplearning4j.nn.conf.layers.OutputLayer;
|
||||||
import org.deeplearning4j.nn.graph.ComputationGraph;
|
import org.deeplearning4j.nn.graph.ComputationGraph;
|
||||||
|
@ -49,7 +48,7 @@ public class RegressionEvalTest extends BaseDL4JTest {
|
||||||
public void testRegressionEvalMethods() {
|
public void testRegressionEvalMethods() {
|
||||||
|
|
||||||
//Basic sanity check
|
//Basic sanity check
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().weightInit(WeightInit.ZERO).list()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().weightInit(WeightInit.ZERO).list()
|
||||||
.layer(0, new OutputLayer.Builder().activation(Activation.TANH)
|
.layer(0, new OutputLayer.Builder().activation(Activation.TANH)
|
||||||
.lossFunction(LossFunctions.LossFunction.MSE).nIn(10).nOut(5).build())
|
.lossFunction(LossFunctions.LossFunction.MSE).nIn(10).nOut(5).build())
|
||||||
.build();
|
.build();
|
||||||
|
@ -71,7 +70,7 @@ public class RegressionEvalTest extends BaseDL4JTest {
|
||||||
|
|
||||||
|
|
||||||
ComputationGraphConfiguration graphConf =
|
ComputationGraphConfiguration graphConf =
|
||||||
new NeuralNetConfiguration.Builder().weightInit(WeightInit.ZERO).graphBuilder()
|
NeuralNetConfiguration.builder().weightInit(WeightInit.ZERO).graphBuilder()
|
||||||
.addInputs("in").addLayer("0", new OutputLayer.Builder()
|
.addInputs("in").addLayer("0", new OutputLayer.Builder()
|
||||||
.lossFunction(LossFunctions.LossFunction.MSE)
|
.lossFunction(LossFunctions.LossFunction.MSE)
|
||||||
.activation(Activation.TANH).nIn(10).nOut(5).build(), "in")
|
.activation(Activation.TANH).nIn(10).nOut(5).build(), "in")
|
||||||
|
|
|
@ -24,7 +24,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import org.deeplearning4j.BaseDL4JTest;
|
import org.deeplearning4j.BaseDL4JTest;
|
||||||
import org.deeplearning4j.exception.DL4JException;
|
import org.deeplearning4j.exception.DL4JException;
|
||||||
import org.deeplearning4j.nn.conf.ConvolutionMode;
|
import org.deeplearning4j.nn.conf.ConvolutionMode;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.inputs.InputType;
|
import org.deeplearning4j.nn.conf.inputs.InputType;
|
||||||
import org.deeplearning4j.nn.conf.layers.*;
|
import org.deeplearning4j.nn.conf.layers.*;
|
||||||
|
@ -41,7 +40,7 @@ import static org.junit.jupiter.api.Assertions.fail;
|
||||||
public class TestInvalidConfigurations extends BaseDL4JTest {
|
public class TestInvalidConfigurations extends BaseDL4JTest {
|
||||||
|
|
||||||
public static MultiLayerNetwork getDensePlusOutput(int nIn, int nOut) {
|
public static MultiLayerNetwork getDensePlusOutput(int nIn, int nOut) {
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().list()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().list()
|
||||||
.layer(0, new DenseLayer.Builder().nIn(nIn).nOut(10).build())
|
.layer(0, new DenseLayer.Builder().nIn(nIn).nOut(10).build())
|
||||||
.layer(1, new OutputLayer.Builder().nIn(10).nOut(nOut).build()).build();
|
.layer(1, new OutputLayer.Builder().nIn(10).nOut(nOut).build()).build();
|
||||||
|
|
||||||
|
@ -52,7 +51,7 @@ public class TestInvalidConfigurations extends BaseDL4JTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MultiLayerNetwork getLSTMPlusRnnOutput(int nIn, int nOut) {
|
public static MultiLayerNetwork getLSTMPlusRnnOutput(int nIn, int nOut) {
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().list()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().list()
|
||||||
.layer(0, new GravesLSTM.Builder().nIn(nIn).nOut(10).build())
|
.layer(0, new GravesLSTM.Builder().nIn(nIn).nOut(10).build())
|
||||||
.layer(1, new RnnOutputLayer.Builder().nIn(10).nOut(nOut).build()).build();
|
.layer(1, new RnnOutputLayer.Builder().nIn(10).nOut(nOut).build()).build();
|
||||||
|
|
||||||
|
@ -63,10 +62,10 @@ public class TestInvalidConfigurations extends BaseDL4JTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MultiLayerNetwork getCnnPlusOutputLayer(int depthIn, int inH, int inW, int nOut) {
|
public static MultiLayerNetwork getCnnPlusOutputLayer(int depthIn, int inH, int inW, int nOut) {
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().list()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().list()
|
||||||
.layer(0, new ConvolutionLayer.Builder().nIn(depthIn).nOut(5).build())
|
.layer(0, new ConvolutionLayer.Builder().nIn(depthIn).nOut(5).build())
|
||||||
.layer(1, new OutputLayer.Builder().nOut(nOut).build())
|
.layer(1, new OutputLayer.Builder().nOut(nOut).build())
|
||||||
.setInputType(InputType.convolutional(inH, inW, depthIn)).build();
|
.inputType(InputType.convolutional(inH, inW, depthIn)).build();
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
net.init();
|
net.init();
|
||||||
|
@ -90,7 +89,7 @@ public class TestInvalidConfigurations extends BaseDL4JTest {
|
||||||
@Test
|
@Test
|
||||||
public void testDenseNout0() {
|
public void testDenseNout0() {
|
||||||
try {
|
try {
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().list()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().list()
|
||||||
.layer(0, new DenseLayer.Builder().nIn(10).nOut(0).build())
|
.layer(0, new DenseLayer.Builder().nIn(10).nOut(0).build())
|
||||||
.layer(1, new OutputLayer.Builder().nIn(10).nOut(10).build()).build();
|
.layer(1, new OutputLayer.Builder().nIn(10).nOut(10).build()).build();
|
||||||
|
|
||||||
|
@ -147,7 +146,7 @@ public class TestInvalidConfigurations extends BaseDL4JTest {
|
||||||
@Test
|
@Test
|
||||||
public void testLSTMNOut0() {
|
public void testLSTMNOut0() {
|
||||||
try {
|
try {
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().list()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().list()
|
||||||
.layer(0, new GravesLSTM.Builder().nIn(10).nOut(0).build())
|
.layer(0, new GravesLSTM.Builder().nIn(10).nOut(0).build())
|
||||||
.layer(1, new RnnOutputLayer.Builder().nIn(10).nOut(10).build()).build();
|
.layer(1, new RnnOutputLayer.Builder().nIn(10).nOut(10).build()).build();
|
||||||
|
|
||||||
|
@ -178,10 +177,10 @@ public class TestInvalidConfigurations extends BaseDL4JTest {
|
||||||
@Test
|
@Test
|
||||||
public void testConvolutionalNOut0() {
|
public void testConvolutionalNOut0() {
|
||||||
try {
|
try {
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().list()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().list()
|
||||||
.layer(0, new ConvolutionLayer.Builder().nIn(5).nOut(0).build())
|
.layer(0, new ConvolutionLayer.Builder().nIn(5).nOut(0).build())
|
||||||
.layer(1, new OutputLayer.Builder().nOut(10).build())
|
.layer(1, new OutputLayer.Builder().nOut(10).build())
|
||||||
.setInputType(InputType.convolutional(10, 10, 5)).build();
|
.inputType(InputType.convolutional(10, 10, 5)).build();
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
net.init();
|
net.init();
|
||||||
|
@ -207,12 +206,12 @@ public class TestInvalidConfigurations extends BaseDL4JTest {
|
||||||
//(10-3+2*0)/2+1 = 7/2 + 1
|
//(10-3+2*0)/2+1 = 7/2 + 1
|
||||||
|
|
||||||
try {
|
try {
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().convolutionMode(ConvolutionMode.Strict)
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().convolutionMode(ConvolutionMode.Strict)
|
||||||
.list()
|
.list()
|
||||||
.layer(0, new ConvolutionLayer.Builder().kernelSize(3, 2).stride(2, 2).padding(0, 0).nOut(5)
|
.layer(0, new ConvolutionLayer.Builder().kernelSize(3, 2).stride(2, 2).padding(0, 0).nOut(5)
|
||||||
.build())
|
.build())
|
||||||
.layer(1, new OutputLayer.Builder().nOut(10).build())
|
.layer(1, new OutputLayer.Builder().nOut(10).build())
|
||||||
.setInputType(InputType.convolutional(hIn, wIn, depthIn)).build();
|
.inputType(InputType.convolutional(hIn, wIn, depthIn)).build();
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
net.init();
|
net.init();
|
||||||
|
@ -234,11 +233,11 @@ public class TestInvalidConfigurations extends BaseDL4JTest {
|
||||||
int hIn = 10;
|
int hIn = 10;
|
||||||
int wIn = 10;
|
int wIn = 10;
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().list()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().list()
|
||||||
.layer(0, new ConvolutionLayer.Builder().kernelSize(7, 7).stride(1, 1).padding(0, 0).nOut(5)
|
.layer(0, new ConvolutionLayer.Builder().kernelSize(7, 7).stride(1, 1).padding(0, 0).nOut(5)
|
||||||
.build())
|
.build())
|
||||||
.layer(1, new OutputLayer.Builder().nOut(10).activation(Activation.SOFTMAX).build())
|
.layer(1, new OutputLayer.Builder().nOut(10).activation(Activation.SOFTMAX).build())
|
||||||
.setInputType(InputType.convolutional(hIn, wIn, depthIn)).build();
|
.inputType(InputType.convolutional(hIn, wIn, depthIn)).build();
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
net.init();
|
net.init();
|
||||||
|
@ -265,8 +264,8 @@ public class TestInvalidConfigurations extends BaseDL4JTest {
|
||||||
|
|
||||||
//Invalid: (10-3+0)/2+1 = 4.5
|
//Invalid: (10-3+0)/2+1 = 4.5
|
||||||
|
|
||||||
MultiLayerConfiguration conf =
|
NeuralNetConfiguration conf =
|
||||||
new NeuralNetConfiguration.Builder().convolutionMode(ConvolutionMode.Strict).list()
|
NeuralNetConfiguration.builder().convolutionMode(ConvolutionMode.Strict).list()
|
||||||
.layer(0, new ConvolutionLayer.Builder().kernelSize(3, 3).stride(2, 2)
|
.layer(0, new ConvolutionLayer.Builder().kernelSize(3, 3).stride(2, 2)
|
||||||
.padding(0, 0).nIn(depthIn).nOut(5).build())
|
.padding(0, 0).nIn(depthIn).nOut(5).build())
|
||||||
.layer(1, new OutputLayer.Builder().nIn(5 * 4 * 4).nOut(10).activation(Activation.SOFTMAX).build())
|
.layer(1, new OutputLayer.Builder().nIn(5 * 4 * 4).nOut(10).activation(Activation.SOFTMAX).build())
|
||||||
|
@ -299,22 +298,22 @@ public class TestInvalidConfigurations extends BaseDL4JTest {
|
||||||
//(10-3+2*0)/2+1 = 7/2 + 1
|
//(10-3+2*0)/2+1 = 7/2 + 1
|
||||||
|
|
||||||
try {
|
try {
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().list()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().list()
|
||||||
.layer(0, new ConvolutionLayer.Builder().kernelSize(2, 3).stride(2, 2).padding(0, 0).nOut(5)
|
.layer(0, new ConvolutionLayer.Builder().kernelSize(2, 3).stride(2, 2).padding(0, 0).nOut(5)
|
||||||
.build())
|
.build())
|
||||||
.layer(1, new OutputLayer.Builder().nOut(10).activation(Activation.SOFTMAX).build())
|
.layer(1, new OutputLayer.Builder().nOut(10).activation(Activation.SOFTMAX).build())
|
||||||
.setInputType(InputType.convolutional(hIn, wIn, depthIn)).build();
|
.inputType(InputType.convolutional(hIn, wIn, depthIn)).build();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
fail("Did not expect exception with default (truncate)");
|
fail("Did not expect exception with default (truncate)");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().convolutionMode(ConvolutionMode.Strict)
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().convolutionMode(ConvolutionMode.Strict)
|
||||||
.list()
|
.list()
|
||||||
.layer(0, new ConvolutionLayer.Builder().kernelSize(2, 3).stride(2, 2).padding(0, 0).nOut(5)
|
.layer(0, new ConvolutionLayer.Builder().kernelSize(2, 3).stride(2, 2).padding(0, 0).nOut(5)
|
||||||
.build())
|
.build())
|
||||||
.layer(1, new OutputLayer.Builder().nOut(10).build())
|
.layer(1, new OutputLayer.Builder().nOut(10).build())
|
||||||
.setInputType(InputType.convolutional(hIn, wIn, depthIn)).build();
|
.inputType(InputType.convolutional(hIn, wIn, depthIn)).build();
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
net.init();
|
net.init();
|
||||||
|
@ -338,12 +337,12 @@ public class TestInvalidConfigurations extends BaseDL4JTest {
|
||||||
//(10-3+2*0)/2+1 = 7/2 + 1
|
//(10-3+2*0)/2+1 = 7/2 + 1
|
||||||
|
|
||||||
try {
|
try {
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().convolutionMode(ConvolutionMode.Strict)
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().convolutionMode(ConvolutionMode.Strict)
|
||||||
.list()
|
.list()
|
||||||
.layer(0, new SubsamplingLayer.Builder().kernelSize(2, 3).stride(2, 2).padding(0, 0)
|
.layer(0, new SubsamplingLayer.Builder().kernelSize(2, 3).stride(2, 2).padding(0, 0)
|
||||||
.build())
|
.build())
|
||||||
.layer(1, new OutputLayer.Builder().nOut(10).build())
|
.layer(1, new OutputLayer.Builder().nOut(10).build())
|
||||||
.setInputType(InputType.convolutional(hIn, wIn, depthIn)).build();
|
.inputType(InputType.convolutional(hIn, wIn, depthIn)).build();
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
net.init();
|
net.init();
|
||||||
|
|
|
@ -23,7 +23,6 @@ package org.deeplearning4j.exceptions;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.deeplearning4j.BaseDL4JTest;
|
import org.deeplearning4j.BaseDL4JTest;
|
||||||
import org.deeplearning4j.exception.DL4JException;
|
import org.deeplearning4j.exception.DL4JException;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.inputs.InputType;
|
import org.deeplearning4j.nn.conf.inputs.InputType;
|
||||||
import org.deeplearning4j.nn.conf.layers.*;
|
import org.deeplearning4j.nn.conf.layers.*;
|
||||||
|
@ -43,7 +42,7 @@ public class TestInvalidInput extends BaseDL4JTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInputNinMismatchDense() {
|
public void testInputNinMismatchDense() {
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().list()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().list()
|
||||||
.layer(0, new DenseLayer.Builder().nIn(10).nOut(10).build())
|
.layer(0, new DenseLayer.Builder().nIn(10).nOut(10).build())
|
||||||
.layer(1, new OutputLayer.Builder().nIn(10).nOut(10).activation(Activation.SOFTMAX).build()).build();
|
.layer(1, new OutputLayer.Builder().nIn(10).nOut(10).activation(Activation.SOFTMAX).build()).build();
|
||||||
|
|
||||||
|
@ -64,7 +63,7 @@ public class TestInvalidInput extends BaseDL4JTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLabelsNOutMismatchOutputLayer() {
|
public void testLabelsNOutMismatchOutputLayer() {
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().list()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().list()
|
||||||
.layer(0, new DenseLayer.Builder().nIn(10).nOut(10).build())
|
.layer(0, new DenseLayer.Builder().nIn(10).nOut(10).build())
|
||||||
.layer(1, new OutputLayer.Builder().nIn(10).nOut(10).activation(Activation.SOFTMAX).build()).build();
|
.layer(1, new OutputLayer.Builder().nIn(10).nOut(10).activation(Activation.SOFTMAX).build()).build();
|
||||||
|
|
||||||
|
@ -85,7 +84,7 @@ public class TestInvalidInput extends BaseDL4JTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLabelsNOutMismatchRnnOutputLayer() {
|
public void testLabelsNOutMismatchRnnOutputLayer() {
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().list()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().list()
|
||||||
.layer(0, new LSTM.Builder().nIn(5).nOut(5).build())
|
.layer(0, new LSTM.Builder().nIn(5).nOut(5).build())
|
||||||
.layer(1, new RnnOutputLayer.Builder().nIn(5).nOut(5).activation(Activation.SOFTMAX).build()).build();
|
.layer(1, new RnnOutputLayer.Builder().nIn(5).nOut(5).activation(Activation.SOFTMAX).build()).build();
|
||||||
|
|
||||||
|
@ -112,10 +111,10 @@ public class TestInvalidInput extends BaseDL4JTest {
|
||||||
int w = 16;
|
int w = 16;
|
||||||
int d = 3;
|
int d = 3;
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().list()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().list()
|
||||||
.layer(0, new ConvolutionLayer.Builder().nIn(d).nOut(5).build())
|
.layer(0, new ConvolutionLayer.Builder().nIn(d).nOut(5).build())
|
||||||
.layer(1, new OutputLayer.Builder().nOut(10).activation(Activation.SOFTMAX).build())
|
.layer(1, new OutputLayer.Builder().nOut(10).activation(Activation.SOFTMAX).build())
|
||||||
.setInputType(InputType.convolutional(h, w, d)).build();
|
.inputType(InputType.convolutional(h, w, d)).build();
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
net.init();
|
net.init();
|
||||||
|
@ -139,10 +138,10 @@ public class TestInvalidInput extends BaseDL4JTest {
|
||||||
int w = 16;
|
int w = 16;
|
||||||
int d = 3;
|
int d = 3;
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().list()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().list()
|
||||||
.layer(0, new ConvolutionLayer.Builder().nIn(d).nOut(5).build())
|
.layer(0, new ConvolutionLayer.Builder().nIn(d).nOut(5).build())
|
||||||
.layer(1, new OutputLayer.Builder().nOut(10).activation(Activation.SOFTMAX).build())
|
.layer(1, new OutputLayer.Builder().nOut(10).activation(Activation.SOFTMAX).build())
|
||||||
.setInputType(InputType.convolutional(h, w, d)).build();
|
.inputType(InputType.convolutional(h, w, d)).build();
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
net.init();
|
net.init();
|
||||||
|
@ -165,10 +164,10 @@ public class TestInvalidInput extends BaseDL4JTest {
|
||||||
int w = 16;
|
int w = 16;
|
||||||
int d = 3;
|
int d = 3;
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().list()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().list()
|
||||||
.layer(0, new SubsamplingLayer.Builder().kernelSize(2, 2).build())
|
.layer(0, new SubsamplingLayer.Builder().kernelSize(2, 2).build())
|
||||||
.layer(1, new OutputLayer.Builder().nOut(10).activation(Activation.SOFTMAX).build())
|
.layer(1, new OutputLayer.Builder().nOut(10).activation(Activation.SOFTMAX).build())
|
||||||
.setInputType(InputType.convolutional(h, w, d)).build();
|
.inputType(InputType.convolutional(h, w, d)).build();
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
net.init();
|
net.init();
|
||||||
|
@ -188,7 +187,7 @@ public class TestInvalidInput extends BaseDL4JTest {
|
||||||
@Test
|
@Test
|
||||||
public void testInputNinMismatchLSTM() {
|
public void testInputNinMismatchLSTM() {
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().list()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().list()
|
||||||
.layer(0, new GravesLSTM.Builder().nIn(5).nOut(5).build())
|
.layer(0, new GravesLSTM.Builder().nIn(5).nOut(5).build())
|
||||||
.layer(1, new RnnOutputLayer.Builder().nIn(5).nOut(5).activation(Activation.SOFTMAX).build()).build();
|
.layer(1, new RnnOutputLayer.Builder().nIn(5).nOut(5).activation(Activation.SOFTMAX).build()).build();
|
||||||
|
|
||||||
|
@ -209,7 +208,7 @@ public class TestInvalidInput extends BaseDL4JTest {
|
||||||
@Test
|
@Test
|
||||||
public void testInputNinMismatchBidirectionalLSTM() {
|
public void testInputNinMismatchBidirectionalLSTM() {
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().list()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().list()
|
||||||
.layer(0, new GravesBidirectionalLSTM.Builder().nIn(5).nOut(5).build())
|
.layer(0, new GravesBidirectionalLSTM.Builder().nIn(5).nOut(5).build())
|
||||||
.layer(1, new RnnOutputLayer.Builder().nIn(5).nOut(5).activation(Activation.SOFTMAX).build()).build();
|
.layer(1, new RnnOutputLayer.Builder().nIn(5).nOut(5).activation(Activation.SOFTMAX).build()).build();
|
||||||
|
|
||||||
|
@ -231,7 +230,7 @@ public class TestInvalidInput extends BaseDL4JTest {
|
||||||
@Test
|
@Test
|
||||||
public void testInputNinMismatchEmbeddingLayer() {
|
public void testInputNinMismatchEmbeddingLayer() {
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().list()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().list()
|
||||||
.layer(0, new EmbeddingLayer.Builder().nIn(10).nOut(10).build())
|
.layer(0, new EmbeddingLayer.Builder().nIn(10).nOut(10).build())
|
||||||
.layer(1, new OutputLayer.Builder().nIn(10).nOut(10).activation(Activation.SOFTMAX).build()).build();
|
.layer(1, new OutputLayer.Builder().nIn(10).nOut(10).activation(Activation.SOFTMAX).build()).build();
|
||||||
|
|
||||||
|
@ -257,7 +256,7 @@ public class TestInvalidInput extends BaseDL4JTest {
|
||||||
|
|
||||||
for(String layerType : new String[]{"simple", "lstm", "graves"}) {
|
for(String layerType : new String[]{"simple", "lstm", "graves"}) {
|
||||||
|
|
||||||
Layer l;
|
LayerConfiguration l;
|
||||||
switch (layerType){
|
switch (layerType){
|
||||||
case "simple":
|
case "simple":
|
||||||
l = new SimpleRnn.Builder().nIn(5).nOut(5).build();
|
l = new SimpleRnn.Builder().nIn(5).nOut(5).build();
|
||||||
|
@ -272,7 +271,7 @@ public class TestInvalidInput extends BaseDL4JTest {
|
||||||
throw new RuntimeException();
|
throw new RuntimeException();
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().list()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().list()
|
||||||
.layer(l)
|
.layer(l)
|
||||||
.layer(new RnnOutputLayer.Builder().nIn(5).nOut(5).activation(Activation.SOFTMAX).build()).build();
|
.layer(new RnnOutputLayer.Builder().nIn(5).nOut(5).activation(Activation.SOFTMAX).build()).build();
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@ package org.deeplearning4j.gradientcheck;
|
||||||
import org.deeplearning4j.BaseDL4JTest;
|
import org.deeplearning4j.BaseDL4JTest;
|
||||||
import org.deeplearning4j.TestUtils;
|
import org.deeplearning4j.TestUtils;
|
||||||
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.graph.AttentionVertex;
|
import org.deeplearning4j.nn.conf.graph.AttentionVertex;
|
||||||
import org.deeplearning4j.nn.conf.inputs.InputType;
|
import org.deeplearning4j.nn.conf.inputs.InputType;
|
||||||
|
@ -84,7 +83,7 @@ public class AttentionLayerTest extends BaseDL4JTest {
|
||||||
System.out.println("Starting test: " + name);
|
System.out.println("Starting test: " + name);
|
||||||
|
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.activation(Activation.TANH)
|
.activation(Activation.TANH)
|
||||||
.updater(new NoOp())
|
.updater(new NoOp())
|
||||||
|
@ -98,7 +97,7 @@ public class AttentionLayerTest extends BaseDL4JTest {
|
||||||
.layer(new GlobalPoolingLayer.Builder().poolingType(PoolingType.MAX).build())
|
.layer(new GlobalPoolingLayer.Builder().poolingType(PoolingType.MAX).build())
|
||||||
.layer(new OutputLayer.Builder().nOut(nOut).activation(Activation.SOFTMAX)
|
.layer(new OutputLayer.Builder().nOut(nOut).activation(Activation.SOFTMAX)
|
||||||
.lossFunction(LossFunctions.LossFunction.MCXENT).build())
|
.lossFunction(LossFunctions.LossFunction.MCXENT).build())
|
||||||
.setInputType(InputType.recurrent(nIn))
|
.inputType(InputType.recurrent(nIn))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
|
@ -145,7 +144,7 @@ public class AttentionLayerTest extends BaseDL4JTest {
|
||||||
System.out.println("Starting test: " + name);
|
System.out.println("Starting test: " + name);
|
||||||
|
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.activation(Activation.TANH)
|
.activation(Activation.TANH)
|
||||||
.updater(new NoOp())
|
.updater(new NoOp())
|
||||||
|
@ -159,7 +158,7 @@ public class AttentionLayerTest extends BaseDL4JTest {
|
||||||
.layer(new GlobalPoolingLayer.Builder().poolingType(PoolingType.MAX).build())
|
.layer(new GlobalPoolingLayer.Builder().poolingType(PoolingType.MAX).build())
|
||||||
.layer(new OutputLayer.Builder().nOut(nOut).activation(Activation.SOFTMAX)
|
.layer(new OutputLayer.Builder().nOut(nOut).activation(Activation.SOFTMAX)
|
||||||
.lossFunction(LossFunctions.LossFunction.MCXENT).build())
|
.lossFunction(LossFunctions.LossFunction.MCXENT).build())
|
||||||
.setInputType(InputType.recurrent(nIn))
|
.inputType(InputType.recurrent(nIn))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
|
@ -185,7 +184,7 @@ public class AttentionLayerTest extends BaseDL4JTest {
|
||||||
for (boolean inputMask : new boolean[]{false, true}) {
|
for (boolean inputMask : new boolean[]{false, true}) {
|
||||||
for (boolean projectInput : new boolean[]{false, true}) {
|
for (boolean projectInput : new boolean[]{false, true}) {
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.activation(Activation.TANH)
|
.activation(Activation.TANH)
|
||||||
.updater(new NoOp())
|
.updater(new NoOp())
|
||||||
|
@ -199,7 +198,7 @@ public class AttentionLayerTest extends BaseDL4JTest {
|
||||||
.layer(new GlobalPoolingLayer.Builder().poolingType(PoolingType.MAX).build())
|
.layer(new GlobalPoolingLayer.Builder().poolingType(PoolingType.MAX).build())
|
||||||
.layer(new OutputLayer.Builder().nOut(nOut).activation(Activation.SOFTMAX)
|
.layer(new OutputLayer.Builder().nOut(nOut).activation(Activation.SOFTMAX)
|
||||||
.lossFunction(LossFunctions.LossFunction.MCXENT).build())
|
.lossFunction(LossFunctions.LossFunction.MCXENT).build())
|
||||||
.setInputType(InputType.recurrent(nIn))
|
.inputType(InputType.recurrent(nIn))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
|
@ -240,7 +239,7 @@ public class AttentionLayerTest extends BaseDL4JTest {
|
||||||
int nOut = 5;
|
int nOut = 5;
|
||||||
int layerSize = 8;
|
int layerSize = 8;
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.activation(Activation.IDENTITY)
|
.activation(Activation.IDENTITY)
|
||||||
.updater(new NoOp())
|
.updater(new NoOp())
|
||||||
|
@ -251,7 +250,7 @@ public class AttentionLayerTest extends BaseDL4JTest {
|
||||||
.layer(new GlobalPoolingLayer.Builder().poolingType(PoolingType.AVG).build())
|
.layer(new GlobalPoolingLayer.Builder().poolingType(PoolingType.AVG).build())
|
||||||
.layer(new OutputLayer.Builder().nOut(nOut).activation(Activation.SOFTMAX)
|
.layer(new OutputLayer.Builder().nOut(nOut).activation(Activation.SOFTMAX)
|
||||||
.lossFunction(LossFunctions.LossFunction.MCXENT).build())
|
.lossFunction(LossFunctions.LossFunction.MCXENT).build())
|
||||||
.setInputType(InputType.recurrent(nIn))
|
.inputType(InputType.recurrent(nIn))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
|
@ -303,7 +302,7 @@ public class AttentionLayerTest extends BaseDL4JTest {
|
||||||
System.out.println("Starting test: " + name);
|
System.out.println("Starting test: " + name);
|
||||||
|
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.activation(Activation.IDENTITY)
|
.activation(Activation.IDENTITY)
|
||||||
.updater(new NoOp())
|
.updater(new NoOp())
|
||||||
|
@ -314,7 +313,7 @@ public class AttentionLayerTest extends BaseDL4JTest {
|
||||||
.layer(new GlobalPoolingLayer.Builder().poolingType(PoolingType.AVG).build())
|
.layer(new GlobalPoolingLayer.Builder().poolingType(PoolingType.AVG).build())
|
||||||
.layer(new OutputLayer.Builder().nOut(nOut).activation(Activation.SOFTMAX)
|
.layer(new OutputLayer.Builder().nOut(nOut).activation(Activation.SOFTMAX)
|
||||||
.lossFunction(LossFunctions.LossFunction.MCXENT).build())
|
.lossFunction(LossFunctions.LossFunction.MCXENT).build())
|
||||||
.setInputType(InputType.recurrent(nIn))
|
.inputType(InputType.recurrent(nIn))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
|
@ -361,7 +360,7 @@ public class AttentionLayerTest extends BaseDL4JTest {
|
||||||
System.out.println("Starting test: " + name);
|
System.out.println("Starting test: " + name);
|
||||||
|
|
||||||
|
|
||||||
ComputationGraphConfiguration graph = new NeuralNetConfiguration.Builder()
|
ComputationGraphConfiguration graph = NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.activation(Activation.TANH)
|
.activation(Activation.TANH)
|
||||||
.updater(new NoOp())
|
.updater(new NoOp())
|
||||||
|
@ -425,7 +424,7 @@ public class AttentionLayerTest extends BaseDL4JTest {
|
||||||
System.out.println("Starting test: " + name);
|
System.out.println("Starting test: " + name);
|
||||||
|
|
||||||
|
|
||||||
ComputationGraphConfiguration graph = new NeuralNetConfiguration.Builder()
|
ComputationGraphConfiguration graph = NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.activation(Activation.TANH)
|
.activation(Activation.TANH)
|
||||||
.updater(new NoOp())
|
.updater(new NoOp())
|
||||||
|
|
|
@ -25,8 +25,8 @@ import org.deeplearning4j.TestUtils;
|
||||||
import org.deeplearning4j.datasets.iterator.impl.IrisDataSetIterator;
|
import org.deeplearning4j.datasets.iterator.impl.IrisDataSetIterator;
|
||||||
import org.deeplearning4j.nn.api.OptimizationAlgorithm;
|
import org.deeplearning4j.nn.api.OptimizationAlgorithm;
|
||||||
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration.NeuralNetConfigurationBuilder;
|
||||||
import org.deeplearning4j.nn.conf.distribution.NormalDistribution;
|
import org.deeplearning4j.nn.conf.distribution.NormalDistribution;
|
||||||
import org.deeplearning4j.nn.conf.distribution.UniformDistribution;
|
import org.deeplearning4j.nn.conf.distribution.UniformDistribution;
|
||||||
import org.deeplearning4j.nn.conf.inputs.InputType;
|
import org.deeplearning4j.nn.conf.inputs.InputType;
|
||||||
|
@ -74,8 +74,8 @@ public class BNGradientCheckTest extends BaseDL4JTest {
|
||||||
|
|
||||||
for (boolean useLogStd : new boolean[]{true, false}) {
|
for (boolean useLogStd : new boolean[]{true, false}) {
|
||||||
|
|
||||||
MultiLayerConfiguration.Builder builder =
|
NeuralNetConfiguration.NeuralNetConfigurationBuilder builder =
|
||||||
new NeuralNetConfiguration.Builder().updater(new NoOp())
|
NeuralNetConfiguration.builder().updater(new NoOp())
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.seed(12345L)
|
.seed(12345L)
|
||||||
.dist(new NormalDistribution(0, 1)).list()
|
.dist(new NormalDistribution(0, 1)).list()
|
||||||
|
@ -119,7 +119,7 @@ public class BNGradientCheckTest extends BaseDL4JTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (boolean useLogStd : new boolean[]{true, false}) {
|
for (boolean useLogStd : new boolean[]{true, false}) {
|
||||||
MultiLayerConfiguration.Builder builder = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration.NeuralNetConfigurationBuilder builder = NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.updater(new NoOp()).seed(12345L)
|
.updater(new NoOp()).seed(12345L)
|
||||||
.dist(new NormalDistribution(0, 2)).list()
|
.dist(new NormalDistribution(0, 2)).list()
|
||||||
|
@ -129,7 +129,7 @@ public class BNGradientCheckTest extends BaseDL4JTest {
|
||||||
.layer(2, new ActivationLayer.Builder().activation(Activation.TANH).build())
|
.layer(2, new ActivationLayer.Builder().activation(Activation.TANH).build())
|
||||||
.layer(3, new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
.layer(3, new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
||||||
.activation(Activation.SOFTMAX).nOut(nOut).build())
|
.activation(Activation.SOFTMAX).nOut(nOut).build())
|
||||||
.setInputType(InputType.convolutional(hw, hw, depth));
|
.inputType(InputType.convolutional(hw, hw, depth));
|
||||||
|
|
||||||
MultiLayerNetwork mln = new MultiLayerNetwork(builder.build());
|
MultiLayerNetwork mln = new MultiLayerNetwork(builder.build());
|
||||||
mln.init();
|
mln.init();
|
||||||
|
@ -188,7 +188,7 @@ public class BNGradientCheckTest extends BaseDL4JTest {
|
||||||
LossFunctions.LossFunction lf = lossFunctions[i];
|
LossFunctions.LossFunction lf = lossFunctions[i];
|
||||||
Activation outputActivation = outputActivations[i];
|
Activation outputActivation = outputActivations[i];
|
||||||
|
|
||||||
MultiLayerConfiguration.Builder builder = new NeuralNetConfiguration.Builder().seed(12345)
|
NeuralNetConfiguration.NeuralNetConfigurationBuilder builder = NeuralNetConfiguration.builder().seed(12345)
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.l2(l2vals[j])
|
.l2(l2vals[j])
|
||||||
.optimizationAlgo(OptimizationAlgorithm.LINE_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.LINE_GRADIENT_DESCENT)
|
||||||
|
@ -203,9 +203,9 @@ public class BNGradientCheckTest extends BaseDL4JTest {
|
||||||
.layer(4, new ActivationLayer.Builder().activation(afn).build())
|
.layer(4, new ActivationLayer.Builder().activation(afn).build())
|
||||||
.layer(5, new OutputLayer.Builder(lf).activation(outputActivation).nOut(nOut)
|
.layer(5, new OutputLayer.Builder(lf).activation(outputActivation).nOut(nOut)
|
||||||
.build())
|
.build())
|
||||||
.setInputType(InputType.convolutional(hw, hw, depth));
|
.inputType(InputType.convolutional(hw, hw, depth));
|
||||||
|
|
||||||
MultiLayerConfiguration conf = builder.build();
|
NeuralNetConfiguration conf = builder.build();
|
||||||
|
|
||||||
MultiLayerNetwork mln = new MultiLayerNetwork(conf);
|
MultiLayerNetwork mln = new MultiLayerNetwork(conf);
|
||||||
mln.init();
|
mln.init();
|
||||||
|
@ -294,8 +294,8 @@ public class BNGradientCheckTest extends BaseDL4JTest {
|
||||||
LossFunctions.LossFunction lf = lossFunctions[i];
|
LossFunctions.LossFunction lf = lossFunctions[i];
|
||||||
Activation outputActivation = outputActivations[i];
|
Activation outputActivation = outputActivations[i];
|
||||||
|
|
||||||
MultiLayerConfiguration.Builder builder =
|
NeuralNetConfiguration.NeuralNetConfigurationBuilder builder =
|
||||||
new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.l2(l2vals[j])
|
.l2(l2vals[j])
|
||||||
.optimizationAlgo(OptimizationAlgorithm.CONJUGATE_GRADIENT)
|
.optimizationAlgo(OptimizationAlgorithm.CONJUGATE_GRADIENT)
|
||||||
|
@ -310,7 +310,7 @@ public class BNGradientCheckTest extends BaseDL4JTest {
|
||||||
.activation(outputActivation).nOut(nOut)
|
.activation(outputActivation).nOut(nOut)
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
MultiLayerConfiguration conf = builder.build();
|
NeuralNetConfiguration conf = builder.build();
|
||||||
|
|
||||||
MultiLayerNetwork mln = new MultiLayerNetwork(conf);
|
MultiLayerNetwork mln = new MultiLayerNetwork(conf);
|
||||||
mln.init();
|
mln.init();
|
||||||
|
@ -370,7 +370,7 @@ public class BNGradientCheckTest extends BaseDL4JTest {
|
||||||
INDArray labels = ds.getLabels();
|
INDArray labels = ds.getLabels();
|
||||||
|
|
||||||
for (boolean useLogStd : new boolean[]{true, false}) {
|
for (boolean useLogStd : new boolean[]{true, false}) {
|
||||||
MultiLayerConfiguration.Builder builder = new NeuralNetConfiguration.Builder().updater(new NoOp())
|
NeuralNetConfiguration.NeuralNetConfigurationBuilder builder = NeuralNetConfiguration.builder().updater(new NoOp())
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.seed(12345L)
|
.seed(12345L)
|
||||||
.dist(new NormalDistribution(0, 1)).list()
|
.dist(new NormalDistribution(0, 1)).list()
|
||||||
|
@ -414,7 +414,7 @@ public class BNGradientCheckTest extends BaseDL4JTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (boolean useLogStd : new boolean[]{true, false}) {
|
for (boolean useLogStd : new boolean[]{true, false}) {
|
||||||
MultiLayerConfiguration.Builder builder = new NeuralNetConfiguration.Builder().updater(new NoOp())
|
NeuralNetConfiguration.NeuralNetConfigurationBuilder builder = NeuralNetConfiguration.builder().updater(new NoOp())
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.seed(12345L)
|
.seed(12345L)
|
||||||
.dist(new NormalDistribution(0, 2)).list()
|
.dist(new NormalDistribution(0, 2)).list()
|
||||||
|
@ -424,7 +424,7 @@ public class BNGradientCheckTest extends BaseDL4JTest {
|
||||||
.layer(2, new ActivationLayer.Builder().activation(Activation.TANH).build())
|
.layer(2, new ActivationLayer.Builder().activation(Activation.TANH).build())
|
||||||
.layer(3, new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
.layer(3, new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
||||||
.activation(Activation.SOFTMAX).nOut(nOut).build())
|
.activation(Activation.SOFTMAX).nOut(nOut).build())
|
||||||
.setInputType(InputType.convolutional(hw, hw, depth));
|
.inputType(InputType.convolutional(hw, hw, depth));
|
||||||
|
|
||||||
MultiLayerNetwork mln = new MultiLayerNetwork(builder.build());
|
MultiLayerNetwork mln = new MultiLayerNetwork(builder.build());
|
||||||
mln.init();
|
mln.init();
|
||||||
|
@ -457,7 +457,7 @@ public class BNGradientCheckTest extends BaseDL4JTest {
|
||||||
|
|
||||||
for (boolean useLogStd : new boolean[]{true, false}) {
|
for (boolean useLogStd : new boolean[]{true, false}) {
|
||||||
|
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().seed(seed).updater(new NoOp())
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder().seed(seed).updater(new NoOp())
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.weightInit(WeightInit.XAVIER).graphBuilder().addInputs("in")
|
.weightInit(WeightInit.XAVIER).graphBuilder().addInputs("in")
|
||||||
.setInputTypes(InputType.convolutional(height, width, channels))
|
.setInputTypes(InputType.convolutional(height, width, channels))
|
||||||
|
@ -526,7 +526,7 @@ public class BNGradientCheckTest extends BaseDL4JTest {
|
||||||
LossFunctions.LossFunction lf = lossFunctions[i];
|
LossFunctions.LossFunction lf = lossFunctions[i];
|
||||||
Activation outputActivation = outputActivations[i];
|
Activation outputActivation = outputActivations[i];
|
||||||
|
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345)
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder().seed(12345)
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.LINE_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.LINE_GRADIENT_DESCENT)
|
||||||
.updater(new NoOp())
|
.updater(new NoOp())
|
||||||
|
|
|
@ -24,17 +24,14 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import org.deeplearning4j.BaseDL4JTest;
|
import org.deeplearning4j.BaseDL4JTest;
|
||||||
import org.deeplearning4j.TestUtils;
|
import org.deeplearning4j.TestUtils;
|
||||||
import org.deeplearning4j.nn.conf.ConvolutionMode;
|
import org.deeplearning4j.nn.conf.ConvolutionMode;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.RNNFormat;
|
import org.deeplearning4j.nn.conf.RNNFormat;
|
||||||
import org.deeplearning4j.nn.conf.distribution.NormalDistribution;
|
import org.deeplearning4j.nn.conf.distribution.NormalDistribution;
|
||||||
import org.deeplearning4j.nn.conf.inputs.InputType;
|
import org.deeplearning4j.nn.conf.inputs.InputType;
|
||||||
import org.deeplearning4j.nn.conf.layers.*;
|
import org.deeplearning4j.nn.conf.layers.*;
|
||||||
import org.deeplearning4j.nn.conf.layers.convolutional.Cropping1D;
|
import org.deeplearning4j.nn.conf.layers.convolutional.Cropping1D;
|
||||||
import org.deeplearning4j.nn.modelimport.keras.KerasModelImport;
|
|
||||||
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
||||||
import org.deeplearning4j.util.Convolution1DUtils;
|
import org.deeplearning4j.util.Convolution1DUtils;
|
||||||
import org.deeplearning4j.util.ConvolutionUtils;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.nd4j.linalg.activations.Activation;
|
import org.nd4j.linalg.activations.Activation;
|
||||||
import org.nd4j.linalg.api.buffer.DataType;
|
import org.nd4j.linalg.api.buffer.DataType;
|
||||||
|
@ -45,8 +42,6 @@ import org.nd4j.linalg.indexing.NDArrayIndex;
|
||||||
import org.nd4j.linalg.learning.config.NoOp;
|
import org.nd4j.linalg.learning.config.NoOp;
|
||||||
import org.nd4j.linalg.lossfunctions.LossFunctions;
|
import org.nd4j.linalg.lossfunctions.LossFunctions;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
@ -90,7 +85,7 @@ public class CNN1DGradientCheckTest extends BaseDL4JTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.updater(new NoOp())
|
.updater(new NoOp())
|
||||||
.dist(new NormalDistribution(0, 1)).convolutionMode(ConvolutionMode.Same).list()
|
.dist(new NormalDistribution(0, 1)).convolutionMode(ConvolutionMode.Same).list()
|
||||||
|
@ -103,10 +98,10 @@ public class CNN1DGradientCheckTest extends BaseDL4JTest {
|
||||||
.build())
|
.build())
|
||||||
.layer(new RnnOutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
.layer(new RnnOutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
||||||
.activation(Activation.SOFTMAX).nOut(finalNOut).build())
|
.activation(Activation.SOFTMAX).nOut(finalNOut).build())
|
||||||
.setInputType(InputType.recurrent(convNIn, length)).build();
|
.inputType(InputType.recurrent(convNIn, length)).build();
|
||||||
|
|
||||||
String json = conf.toJson();
|
String json = conf.toJson();
|
||||||
MultiLayerConfiguration c2 = MultiLayerConfiguration.fromJson(json);
|
NeuralNetConfiguration c2 = NeuralNetConfiguration.fromJson(json);
|
||||||
assertEquals(conf, c2);
|
assertEquals(conf, c2);
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
|
@ -170,7 +165,7 @@ public class CNN1DGradientCheckTest extends BaseDL4JTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.updater(new NoOp())
|
.updater(new NoOp())
|
||||||
.dist(new NormalDistribution(0, 1)).convolutionMode(ConvolutionMode.Same).list()
|
.dist(new NormalDistribution(0, 1)).convolutionMode(ConvolutionMode.Same).list()
|
||||||
|
@ -183,10 +178,10 @@ public class CNN1DGradientCheckTest extends BaseDL4JTest {
|
||||||
.build())
|
.build())
|
||||||
.layer(new RnnOutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
.layer(new RnnOutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
||||||
.activation(Activation.SOFTMAX).nOut(finalNOut).build())
|
.activation(Activation.SOFTMAX).nOut(finalNOut).build())
|
||||||
.setInputType(InputType.recurrent(convNIn, length,RNNFormat.NCW)).build();
|
.inputType(InputType.recurrent(convNIn, length,RNNFormat.NCW)).build();
|
||||||
|
|
||||||
String json = conf.toJson();
|
String json = conf.toJson();
|
||||||
MultiLayerConfiguration c2 = MultiLayerConfiguration.fromJson(json);
|
NeuralNetConfiguration c2 = NeuralNetConfiguration.fromJson(json);
|
||||||
assertEquals(conf, c2);
|
assertEquals(conf, c2);
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
|
@ -251,7 +246,7 @@ public class CNN1DGradientCheckTest extends BaseDL4JTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.updater(new NoOp())
|
.updater(new NoOp())
|
||||||
.dist(new NormalDistribution(0, 1)).convolutionMode(ConvolutionMode.Same).list()
|
.dist(new NormalDistribution(0, 1)).convolutionMode(ConvolutionMode.Same).list()
|
||||||
|
@ -267,10 +262,10 @@ public class CNN1DGradientCheckTest extends BaseDL4JTest {
|
||||||
.stride(stride).padding(padding).pnorm(pnorm).build())
|
.stride(stride).padding(padding).pnorm(pnorm).build())
|
||||||
.layer(new RnnOutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
.layer(new RnnOutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
||||||
.activation(Activation.SOFTMAX).nOut(finalNOut).build())
|
.activation(Activation.SOFTMAX).nOut(finalNOut).build())
|
||||||
.setInputType(InputType.recurrent(convNIn, length,RNNFormat.NCW)).build();
|
.inputType(InputType.recurrent(convNIn, length,RNNFormat.NCW)).build();
|
||||||
|
|
||||||
String json = conf.toJson();
|
String json = conf.toJson();
|
||||||
MultiLayerConfiguration c2 = MultiLayerConfiguration.fromJson(json);
|
NeuralNetConfiguration c2 = NeuralNetConfiguration.fromJson(json);
|
||||||
assertEquals(conf, c2);
|
assertEquals(conf, c2);
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
|
@ -330,7 +325,7 @@ public class CNN1DGradientCheckTest extends BaseDL4JTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.updater(new NoOp())
|
.updater(new NoOp())
|
||||||
.dist(new NormalDistribution(0, 1)).convolutionMode(ConvolutionMode.Same).list()
|
.dist(new NormalDistribution(0, 1)).convolutionMode(ConvolutionMode.Same).list()
|
||||||
|
@ -344,10 +339,10 @@ public class CNN1DGradientCheckTest extends BaseDL4JTest {
|
||||||
.stride(stride).padding(padding).pnorm(pnorm).build())
|
.stride(stride).padding(padding).pnorm(pnorm).build())
|
||||||
.layer(3, new RnnOutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
.layer(3, new RnnOutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
||||||
.activation(Activation.SOFTMAX).nOut(finalNOut).build())
|
.activation(Activation.SOFTMAX).nOut(finalNOut).build())
|
||||||
.setInputType(InputType.recurrent(convNIn, length,RNNFormat.NCW)).build();
|
.inputType(InputType.recurrent(convNIn, length,RNNFormat.NCW)).build();
|
||||||
|
|
||||||
String json = conf.toJson();
|
String json = conf.toJson();
|
||||||
MultiLayerConfiguration c2 = MultiLayerConfiguration.fromJson(json);
|
NeuralNetConfiguration c2 = NeuralNetConfiguration.fromJson(json);
|
||||||
assertEquals(conf, c2);
|
assertEquals(conf, c2);
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
|
@ -393,7 +388,7 @@ public class CNN1DGradientCheckTest extends BaseDL4JTest {
|
||||||
log.info("Starting test: " + s);
|
log.info("Starting test: " + s);
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.updater(new NoOp())
|
.updater(new NoOp())
|
||||||
.activation(Activation.TANH)
|
.activation(Activation.TANH)
|
||||||
|
@ -413,7 +408,7 @@ public class CNN1DGradientCheckTest extends BaseDL4JTest {
|
||||||
.layer(new GlobalPoolingLayer(PoolingType.AVG))
|
.layer(new GlobalPoolingLayer(PoolingType.AVG))
|
||||||
.layer(new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
.layer(new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
||||||
.activation(Activation.SOFTMAX).nOut(finalNOut).build())
|
.activation(Activation.SOFTMAX).nOut(finalNOut).build())
|
||||||
.setInputType(InputType.recurrent(convNIn, length)).build();
|
.inputType(InputType.recurrent(convNIn, length)).build();
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
net.init();
|
net.init();
|
||||||
|
@ -481,7 +476,7 @@ public class CNN1DGradientCheckTest extends BaseDL4JTest {
|
||||||
log.info("Starting test: " + s);
|
log.info("Starting test: " + s);
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.updater(new NoOp())
|
.updater(new NoOp())
|
||||||
.activation(Activation.TANH)
|
.activation(Activation.TANH)
|
||||||
|
@ -501,7 +496,7 @@ public class CNN1DGradientCheckTest extends BaseDL4JTest {
|
||||||
.build())
|
.build())
|
||||||
.layer(new RnnOutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
.layer(new RnnOutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
||||||
.activation(Activation.SOFTMAX).nOut(finalNOut).build())
|
.activation(Activation.SOFTMAX).nOut(finalNOut).build())
|
||||||
.setInputType(InputType.recurrent(convNIn, length,RNNFormat.NCW)).build();
|
.inputType(InputType.recurrent(convNIn, length,RNNFormat.NCW)).build();
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
net.init();
|
net.init();
|
||||||
|
|
|
@ -24,7 +24,6 @@ import lombok.extern.java.Log;
|
||||||
import org.deeplearning4j.BaseDL4JTest;
|
import org.deeplearning4j.BaseDL4JTest;
|
||||||
import org.deeplearning4j.TestUtils;
|
import org.deeplearning4j.TestUtils;
|
||||||
import org.deeplearning4j.nn.conf.ConvolutionMode;
|
import org.deeplearning4j.nn.conf.ConvolutionMode;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.distribution.NormalDistribution;
|
import org.deeplearning4j.nn.conf.distribution.NormalDistribution;
|
||||||
import org.deeplearning4j.nn.conf.inputs.InputType;
|
import org.deeplearning4j.nn.conf.inputs.InputType;
|
||||||
|
@ -35,7 +34,6 @@ import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
||||||
import org.deeplearning4j.nn.weights.WeightInit;
|
import org.deeplearning4j.nn.weights.WeightInit;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.nd4j.linalg.activations.Activation;
|
import org.nd4j.linalg.activations.Activation;
|
||||||
import org.nd4j.linalg.api.buffer.DataBuffer;
|
|
||||||
import org.nd4j.linalg.api.buffer.DataType;
|
import org.nd4j.linalg.api.buffer.DataType;
|
||||||
import org.nd4j.linalg.api.ndarray.INDArray;
|
import org.nd4j.linalg.api.ndarray.INDArray;
|
||||||
import org.nd4j.linalg.factory.Nd4j;
|
import org.nd4j.linalg.factory.Nd4j;
|
||||||
|
@ -112,7 +110,7 @@ public class CNN3DGradientCheckTest extends BaseDL4JTest {
|
||||||
labels.putScalar(new int[]{i, i % finalNOut}, 1.0);
|
labels.putScalar(new int[]{i, i % finalNOut}, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.updater(new NoOp()).weightInit(WeightInit.LECUN_NORMAL)
|
.updater(new NoOp()).weightInit(WeightInit.LECUN_NORMAL)
|
||||||
.dist(new NormalDistribution(0, 1))
|
.dist(new NormalDistribution(0, 1))
|
||||||
|
@ -131,10 +129,10 @@ public class CNN3DGradientCheckTest extends BaseDL4JTest {
|
||||||
.inputPreProcessor(2,
|
.inputPreProcessor(2,
|
||||||
new Cnn3DToFeedForwardPreProcessor(outDepth, outHeight, outWidth,
|
new Cnn3DToFeedForwardPreProcessor(outDepth, outHeight, outWidth,
|
||||||
convNOut2, df == Convolution3D.DataFormat.NCDHW))
|
convNOut2, df == Convolution3D.DataFormat.NCDHW))
|
||||||
.setInputType(InputType.convolutional3D(df, depth, height, width, convNIn)).build();
|
.inputType(InputType.convolutional3D(df, depth, height, width, convNIn)).build();
|
||||||
|
|
||||||
String json = conf.toJson();
|
String json = conf.toJson();
|
||||||
MultiLayerConfiguration c2 = MultiLayerConfiguration.fromJson(json);
|
NeuralNetConfiguration c2 = NeuralNetConfiguration.fromJson(json);
|
||||||
assertEquals(conf, c2);
|
assertEquals(conf, c2);
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
|
@ -215,7 +213,7 @@ public class CNN3DGradientCheckTest extends BaseDL4JTest {
|
||||||
labels.putScalar(new int[]{i, i % finalNOut}, 1.0);
|
labels.putScalar(new int[]{i, i % finalNOut}, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.updater(new NoOp()).weightInit(WeightInit.LECUN_NORMAL)
|
.updater(new NoOp()).weightInit(WeightInit.LECUN_NORMAL)
|
||||||
.dist(new NormalDistribution(0, 1))
|
.dist(new NormalDistribution(0, 1))
|
||||||
|
@ -235,10 +233,10 @@ public class CNN3DGradientCheckTest extends BaseDL4JTest {
|
||||||
.inputPreProcessor(3,
|
.inputPreProcessor(3,
|
||||||
new Cnn3DToFeedForwardPreProcessor(outDepth, outHeight, outWidth,
|
new Cnn3DToFeedForwardPreProcessor(outDepth, outHeight, outWidth,
|
||||||
convNOut2, true))
|
convNOut2, true))
|
||||||
.setInputType(InputType.convolutional3D(depth, height, width, convNIn)).build();
|
.inputType(InputType.convolutional3D(depth, height, width, convNIn)).build();
|
||||||
|
|
||||||
String json = conf.toJson();
|
String json = conf.toJson();
|
||||||
MultiLayerConfiguration c2 = MultiLayerConfiguration.fromJson(json);
|
NeuralNetConfiguration c2 = NeuralNetConfiguration.fromJson(json);
|
||||||
assertEquals(conf, c2);
|
assertEquals(conf, c2);
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
|
@ -310,7 +308,7 @@ public class CNN3DGradientCheckTest extends BaseDL4JTest {
|
||||||
labels.putScalar(new int[]{i, i % finalNOut}, 1.0);
|
labels.putScalar(new int[]{i, i % finalNOut}, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.updater(new NoOp())
|
.updater(new NoOp())
|
||||||
.weightInit(WeightInit.XAVIER)
|
.weightInit(WeightInit.XAVIER)
|
||||||
|
@ -327,10 +325,10 @@ public class CNN3DGradientCheckTest extends BaseDL4JTest {
|
||||||
.activation(Activation.SOFTMAX).nOut(finalNOut).build())
|
.activation(Activation.SOFTMAX).nOut(finalNOut).build())
|
||||||
.inputPreProcessor(2,
|
.inputPreProcessor(2,
|
||||||
new Cnn3DToFeedForwardPreProcessor(outDepth, outHeight, outWidth,convNOut, df))
|
new Cnn3DToFeedForwardPreProcessor(outDepth, outHeight, outWidth,convNOut, df))
|
||||||
.setInputType(InputType.convolutional3D(df, depth, height, width, convNIn)).build();
|
.inputType(InputType.convolutional3D(df, depth, height, width, convNIn)).build();
|
||||||
|
|
||||||
String json = conf.toJson();
|
String json = conf.toJson();
|
||||||
MultiLayerConfiguration c2 = MultiLayerConfiguration.fromJson(json);
|
NeuralNetConfiguration c2 = NeuralNetConfiguration.fromJson(json);
|
||||||
assertEquals(conf, c2);
|
assertEquals(conf, c2);
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
|
@ -397,7 +395,7 @@ public class CNN3DGradientCheckTest extends BaseDL4JTest {
|
||||||
labels.putScalar(new int[]{i, i % finalNOut}, 1.0);
|
labels.putScalar(new int[]{i, i % finalNOut}, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.updater(new NoOp()).weightInit(WeightInit.LECUN_NORMAL)
|
.updater(new NoOp()).weightInit(WeightInit.LECUN_NORMAL)
|
||||||
.dist(new NormalDistribution(0, 1))
|
.dist(new NormalDistribution(0, 1))
|
||||||
|
@ -414,10 +412,10 @@ public class CNN3DGradientCheckTest extends BaseDL4JTest {
|
||||||
.inputPreProcessor(2,
|
.inputPreProcessor(2,
|
||||||
new Cnn3DToFeedForwardPreProcessor(outDepth, outHeight, outWidth,
|
new Cnn3DToFeedForwardPreProcessor(outDepth, outHeight, outWidth,
|
||||||
convNOut, true))
|
convNOut, true))
|
||||||
.setInputType(InputType.convolutional3D(df, depth, height, width, convNIn)).build();
|
.inputType(InputType.convolutional3D(df, depth, height, width, convNIn)).build();
|
||||||
|
|
||||||
String json = conf.toJson();
|
String json = conf.toJson();
|
||||||
MultiLayerConfiguration c2 = MultiLayerConfiguration.fromJson(json);
|
NeuralNetConfiguration c2 = NeuralNetConfiguration.fromJson(json);
|
||||||
assertEquals(conf, c2);
|
assertEquals(conf, c2);
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
|
@ -493,7 +491,7 @@ public class CNN3DGradientCheckTest extends BaseDL4JTest {
|
||||||
labels.putScalar(new int[]{i, i % finalNOut}, 1.0);
|
labels.putScalar(new int[]{i, i % finalNOut}, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.updater(new NoOp()).weightInit(WeightInit.LECUN_NORMAL)
|
.updater(new NoOp()).weightInit(WeightInit.LECUN_NORMAL)
|
||||||
.dist(new NormalDistribution(0, 1))
|
.dist(new NormalDistribution(0, 1))
|
||||||
|
@ -513,10 +511,10 @@ public class CNN3DGradientCheckTest extends BaseDL4JTest {
|
||||||
.inputPreProcessor(3,
|
.inputPreProcessor(3,
|
||||||
new Cnn3DToFeedForwardPreProcessor(outDepth, outHeight, outWidth,
|
new Cnn3DToFeedForwardPreProcessor(outDepth, outHeight, outWidth,
|
||||||
convNOut2, true))
|
convNOut2, true))
|
||||||
.setInputType(InputType.convolutional3D(depth, height, width, convNIn)).build();
|
.inputType(InputType.convolutional3D(depth, height, width, convNIn)).build();
|
||||||
|
|
||||||
String json = conf.toJson();
|
String json = conf.toJson();
|
||||||
MultiLayerConfiguration c2 = MultiLayerConfiguration.fromJson(json);
|
NeuralNetConfiguration c2 = NeuralNetConfiguration.fromJson(json);
|
||||||
assertEquals(conf, c2);
|
assertEquals(conf, c2);
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
|
@ -592,7 +590,7 @@ public class CNN3DGradientCheckTest extends BaseDL4JTest {
|
||||||
labels.putScalar(new int[]{j, j % finalNOut}, 1.0);
|
labels.putScalar(new int[]{j, j % finalNOut}, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.updater(new NoOp())
|
.updater(new NoOp())
|
||||||
.weightInit(new NormalDistribution(0, 0.1))
|
.weightInit(new NormalDistribution(0, 0.1))
|
||||||
|
@ -607,10 +605,10 @@ public class CNN3DGradientCheckTest extends BaseDL4JTest {
|
||||||
.build())
|
.build())
|
||||||
.layer(new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
.layer(new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
||||||
.activation(Activation.SOFTMAX).nOut(finalNOut).build())
|
.activation(Activation.SOFTMAX).nOut(finalNOut).build())
|
||||||
.setInputType(InputType.convolutional3D(df, depth, height, width, convNIn)).build();
|
.inputType(InputType.convolutional3D(df, depth, height, width, convNIn)).build();
|
||||||
|
|
||||||
String json = conf.toJson();
|
String json = conf.toJson();
|
||||||
MultiLayerConfiguration c2 = MultiLayerConfiguration.fromJson(json);
|
NeuralNetConfiguration c2 = NeuralNetConfiguration.fromJson(json);
|
||||||
assertEquals(conf, c2);
|
assertEquals(conf, c2);
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
|
|
|
@ -26,8 +26,8 @@ import org.deeplearning4j.datasets.iterator.impl.IrisDataSetIterator;
|
||||||
import org.deeplearning4j.nn.api.OptimizationAlgorithm;
|
import org.deeplearning4j.nn.api.OptimizationAlgorithm;
|
||||||
import org.deeplearning4j.nn.conf.CNN2DFormat;
|
import org.deeplearning4j.nn.conf.CNN2DFormat;
|
||||||
import org.deeplearning4j.nn.conf.ConvolutionMode;
|
import org.deeplearning4j.nn.conf.ConvolutionMode;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration.NeuralNetConfigurationBuilder;
|
||||||
import org.deeplearning4j.nn.conf.distribution.NormalDistribution;
|
import org.deeplearning4j.nn.conf.distribution.NormalDistribution;
|
||||||
import org.deeplearning4j.nn.conf.inputs.InputType;
|
import org.deeplearning4j.nn.conf.inputs.InputType;
|
||||||
import org.deeplearning4j.nn.conf.layers.*;
|
import org.deeplearning4j.nn.conf.layers.*;
|
||||||
|
@ -100,15 +100,15 @@ public class CNNGradientCheckTest extends BaseDL4JTest {
|
||||||
LossFunctions.LossFunction lf = lossFunctions[i];
|
LossFunctions.LossFunction lf = lossFunctions[i];
|
||||||
Activation outputActivation = outputActivations[i];
|
Activation outputActivation = outputActivations[i];
|
||||||
|
|
||||||
MultiLayerConfiguration.Builder builder = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration.NeuralNetConfigurationBuilder builder = NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.CONJUGATE_GRADIENT).updater(new NoOp())
|
.optimizationAlgo(OptimizationAlgorithm.CONJUGATE_GRADIENT).updater(new NoOp())
|
||||||
.weightInit(WeightInit.XAVIER).seed(12345L).list()
|
.weightInit(WeightInit.XAVIER).seed(12345L).list()
|
||||||
.layer(0, new ConvolutionLayer.Builder(1, 1).nOut(6).activation(afn).build())
|
.layer(0, new ConvolutionLayer.Builder(1, 1).nOut(6).activation(afn).build())
|
||||||
.layer(1, new OutputLayer.Builder(lf).activation(outputActivation).nOut(3).build())
|
.layer(1, new OutputLayer.Builder(lf).activation(outputActivation).nOut(3).build())
|
||||||
.setInputType(InputType.convolutionalFlat(1, 4, 1));
|
.inputType(InputType.convolutionalFlat(1, 4, 1));
|
||||||
|
|
||||||
MultiLayerConfiguration conf = builder.build();
|
NeuralNetConfiguration conf = builder.build();
|
||||||
|
|
||||||
MultiLayerNetwork mln = new MultiLayerNetwork(conf);
|
MultiLayerNetwork mln = new MultiLayerNetwork(conf);
|
||||||
mln.init();
|
mln.init();
|
||||||
|
@ -186,7 +186,7 @@ public class CNNGradientCheckTest extends BaseDL4JTest {
|
||||||
double l2 = l2vals[i];
|
double l2 = l2vals[i];
|
||||||
double l1 = l1vals[i];
|
double l1 = l1vals[i];
|
||||||
|
|
||||||
MultiLayerConfiguration.Builder builder = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration.NeuralNetConfigurationBuilder builder = NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.l2(l2).l1(l1).l2Bias(biasL2[i]).l1Bias(biasL1[i])
|
.l2(l2).l1(l1).l2Bias(biasL2[i]).l1Bias(biasL1[i])
|
||||||
.optimizationAlgo(
|
.optimizationAlgo(
|
||||||
|
@ -198,9 +198,9 @@ public class CNNGradientCheckTest extends BaseDL4JTest {
|
||||||
.layer(1, new OutputLayer.Builder(lf).activation(outputActivation).nOut(3)
|
.layer(1, new OutputLayer.Builder(lf).activation(outputActivation).nOut(3)
|
||||||
.weightInit(WeightInit.XAVIER).updater(new NoOp()).build())
|
.weightInit(WeightInit.XAVIER).updater(new NoOp()).build())
|
||||||
|
|
||||||
.setInputType(InputType.convolutionalFlat(1, 4, 1));
|
.inputType(InputType.convolutionalFlat(1, 4, 1));
|
||||||
|
|
||||||
MultiLayerConfiguration conf = builder.build();
|
NeuralNetConfiguration conf = builder.build();
|
||||||
|
|
||||||
MultiLayerNetwork mln = new MultiLayerNetwork(conf);
|
MultiLayerNetwork mln = new MultiLayerNetwork(conf);
|
||||||
mln.init();
|
mln.init();
|
||||||
|
@ -269,8 +269,8 @@ public class CNNGradientCheckTest extends BaseDL4JTest {
|
||||||
labels.putScalar(new int[]{i, i % nOut}, 1.0);
|
labels.putScalar(new int[]{i, i % nOut}, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiLayerConfiguration conf =
|
NeuralNetConfiguration conf =
|
||||||
new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.updater(new NoOp())
|
.updater(new NoOp())
|
||||||
.dist(new NormalDistribution(0, 1))
|
.dist(new NormalDistribution(0, 1))
|
||||||
|
@ -281,7 +281,7 @@ public class CNNGradientCheckTest extends BaseDL4JTest {
|
||||||
.layer(new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
.layer(new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
||||||
.activation(Activation.SOFTMAX).nIn(2 * 2 * 4)
|
.activation(Activation.SOFTMAX).nIn(2 * 2 * 4)
|
||||||
.nOut(nOut).build())
|
.nOut(nOut).build())
|
||||||
.setInputType(InputType.convolutionalFlat(height, width, inputDepth))
|
.inputType(InputType.convolutionalFlat(height, width, inputDepth))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
|
@ -334,8 +334,8 @@ public class CNNGradientCheckTest extends BaseDL4JTest {
|
||||||
labels.putScalar(new int[]{i, i % nOut}, 1.0);
|
labels.putScalar(new int[]{i, i % nOut}, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiLayerConfiguration conf =
|
NeuralNetConfiguration conf =
|
||||||
new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.updater(new NoOp()).weightInit(new NormalDistribution(0, 1))
|
.updater(new NoOp()).weightInit(new NormalDistribution(0, 1))
|
||||||
.list()
|
.list()
|
||||||
|
@ -349,7 +349,7 @@ public class CNNGradientCheckTest extends BaseDL4JTest {
|
||||||
.layer(new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
.layer(new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
||||||
.activation(Activation.SOFTMAX)
|
.activation(Activation.SOFTMAX)
|
||||||
.nOut(nOut).build())
|
.nOut(nOut).build())
|
||||||
.setInputType(InputType.convolutional(height, width, inputDepth, format))
|
.inputType(InputType.convolutional(height, width, inputDepth, format))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
|
@ -403,8 +403,8 @@ public class CNNGradientCheckTest extends BaseDL4JTest {
|
||||||
INDArray input = Nd4j.rand(DataType.DOUBLE, inShape);
|
INDArray input = Nd4j.rand(DataType.DOUBLE, inShape);
|
||||||
INDArray labels = TestUtils.randomOneHot(minibatchSize, nOut);
|
INDArray labels = TestUtils.randomOneHot(minibatchSize, nOut);
|
||||||
|
|
||||||
MultiLayerConfiguration conf =
|
NeuralNetConfiguration conf =
|
||||||
new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.updater(new NoOp())
|
.updater(new NoOp())
|
||||||
.dist(new NormalDistribution(0, 1))
|
.dist(new NormalDistribution(0, 1))
|
||||||
|
@ -416,7 +416,7 @@ public class CNNGradientCheckTest extends BaseDL4JTest {
|
||||||
.layer(new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
.layer(new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
||||||
.activation(Activation.SOFTMAX).nIn(8 * 8 * 3)
|
.activation(Activation.SOFTMAX).nIn(8 * 8 * 3)
|
||||||
.nOut(4).build())
|
.nOut(4).build())
|
||||||
.setInputType(InputType.convolutional(height, width, inputDepth, format))
|
.inputType(InputType.convolutional(height, width, inputDepth, format))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
|
@ -472,8 +472,8 @@ public class CNNGradientCheckTest extends BaseDL4JTest {
|
||||||
labels.putScalar(new int[]{i, i % nOut}, 1.0);
|
labels.putScalar(new int[]{i, i % nOut}, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiLayerConfiguration conf =
|
NeuralNetConfiguration conf =
|
||||||
new NeuralNetConfiguration.Builder().updater(new NoOp())
|
NeuralNetConfiguration.builder().updater(new NoOp())
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.dist(new NormalDistribution(0, 1))
|
.dist(new NormalDistribution(0, 1))
|
||||||
.list().layer(0,
|
.list().layer(0,
|
||||||
|
@ -488,7 +488,7 @@ public class CNNGradientCheckTest extends BaseDL4JTest {
|
||||||
.layer(2, new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
.layer(2, new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
||||||
.activation(Activation.SOFTMAX).nIn(3 * 3 * 3)
|
.activation(Activation.SOFTMAX).nIn(3 * 3 * 3)
|
||||||
.nOut(4).build())
|
.nOut(4).build())
|
||||||
.setInputType(InputType.convolutional(height, width, inputDepth, format))
|
.inputType(InputType.convolutional(height, width, inputDepth, format))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
|
@ -546,8 +546,8 @@ public class CNNGradientCheckTest extends BaseDL4JTest {
|
||||||
labels.putScalar(new int[]{i, i % nOut}, 1.0);
|
labels.putScalar(new int[]{i, i % nOut}, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiLayerConfiguration conf =
|
NeuralNetConfiguration conf =
|
||||||
new NeuralNetConfiguration.Builder().updater(new NoOp())
|
NeuralNetConfiguration.builder().updater(new NoOp())
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.dist(new NormalDistribution(0, 1))
|
.dist(new NormalDistribution(0, 1))
|
||||||
.list().layer(0,
|
.list().layer(0,
|
||||||
|
@ -562,7 +562,7 @@ public class CNNGradientCheckTest extends BaseDL4JTest {
|
||||||
.layer(3, new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
.layer(3, new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
||||||
.activation(Activation.SOFTMAX).nIn(2 * 2 * 2)
|
.activation(Activation.SOFTMAX).nIn(2 * 2 * 2)
|
||||||
.nOut(4).build())
|
.nOut(4).build())
|
||||||
.setInputType(InputType.convolutional(height, width, inputDepth, format))
|
.inputType(InputType.convolutional(height, width, inputDepth, format))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
|
@ -606,7 +606,7 @@ public class CNNGradientCheckTest extends BaseDL4JTest {
|
||||||
INDArray input = Nd4j.rand(DataType.DOUBLE, inShape);
|
INDArray input = Nd4j.rand(DataType.DOUBLE, inShape);
|
||||||
INDArray labels = TestUtils.randomOneHot(minibatchSize, nOut);
|
INDArray labels = TestUtils.randomOneHot(minibatchSize, nOut);
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345).updater(new NoOp())
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().seed(12345).updater(new NoOp())
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.activation(afn)
|
.activation(afn)
|
||||||
.list()
|
.list()
|
||||||
|
@ -623,10 +623,9 @@ public class CNNGradientCheckTest extends BaseDL4JTest {
|
||||||
.layer(3, new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
.layer(3, new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
||||||
.activation(Activation.SOFTMAX).nIn(2 * 2 * 2).nOut(nOut)
|
.activation(Activation.SOFTMAX).nIn(2 * 2 * 2).nOut(nOut)
|
||||||
.build())
|
.build())
|
||||||
.setInputType(InputType.convolutional(height, width, inputDepth, format)).build();
|
.inputType(InputType.convolutional(height, width, inputDepth, format)).build();
|
||||||
|
|
||||||
assertEquals(ConvolutionMode.Truncate,
|
assertEquals(ConvolutionMode.Truncate, conf.getConvolutionMode());
|
||||||
((ConvolutionLayer) conf.getConf(0).getLayer()).getConvolutionMode());
|
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
net.init();
|
net.init();
|
||||||
|
@ -673,7 +672,7 @@ public class CNNGradientCheckTest extends BaseDL4JTest {
|
||||||
labels.putScalar(new int[]{i, i % nOut}, 1.0);
|
labels.putScalar(new int[]{i, i % nOut}, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345).updater(new NoOp())
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().seed(12345).updater(new NoOp())
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.activation(afn)
|
.activation(afn)
|
||||||
.list()
|
.list()
|
||||||
|
@ -689,10 +688,9 @@ public class CNNGradientCheckTest extends BaseDL4JTest {
|
||||||
.layer(3, new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
.layer(3, new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
||||||
.activation(Activation.SOFTMAX).nIn(2 * 2 * 2).nOut(nOut)
|
.activation(Activation.SOFTMAX).nIn(2 * 2 * 2).nOut(nOut)
|
||||||
.build())
|
.build())
|
||||||
.setInputType(InputType.convolutional(height, width, inputDepth, format)).build();
|
.inputType(InputType.convolutional(height, width, inputDepth, format)).build();
|
||||||
|
|
||||||
assertEquals(ConvolutionMode.Truncate,
|
assertEquals(ConvolutionMode.Truncate,conf.getConvolutionMode());
|
||||||
((ConvolutionLayer) conf.getConf(0).getLayer()).getConvolutionMode());
|
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
net.init();
|
net.init();
|
||||||
|
@ -744,7 +742,7 @@ public class CNNGradientCheckTest extends BaseDL4JTest {
|
||||||
|
|
||||||
INDArray labels = TestUtils.randomOneHot(minibatchSize, nOut);
|
INDArray labels = TestUtils.randomOneHot(minibatchSize, nOut);
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345)
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().seed(12345)
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.updater(new NoOp())
|
.updater(new NoOp())
|
||||||
.activation(Activation.SIGMOID).convolutionMode(Same).list()
|
.activation(Activation.SIGMOID).convolutionMode(Same).list()
|
||||||
|
@ -760,7 +758,7 @@ public class CNNGradientCheckTest extends BaseDL4JTest {
|
||||||
.stride(1, 1).padding(0, 0).build())
|
.stride(1, 1).padding(0, 0).build())
|
||||||
.layer(3, new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
.layer(3, new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
||||||
.activation(Activation.SOFTMAX).nOut(nOut).build())
|
.activation(Activation.SOFTMAX).nOut(nOut).build())
|
||||||
.setInputType(InputType.convolutional(height, width, inputDepth, format)).build();
|
.inputType(InputType.convolutional(height, width, inputDepth, format)).build();
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
net.init();
|
net.init();
|
||||||
|
@ -810,14 +808,14 @@ public class CNNGradientCheckTest extends BaseDL4JTest {
|
||||||
labels.putScalar(new int[]{i, i % nOut}, 1.0);
|
labels.putScalar(new int[]{i, i % nOut}, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Layer convLayer = new ConvolutionLayer.Builder().name("layer 0").kernelSize(k, k).dataFormat(format)
|
LayerConfiguration convLayer = new ConvolutionLayer.Builder().name("layer 0").kernelSize(k, k).dataFormat(format)
|
||||||
.stride(stride, stride).padding(0, 0).nIn(inputDepth).nOut(2).build();
|
.stride(stride, stride).padding(0, 0).nIn(inputDepth).nOut(2).build();
|
||||||
|
|
||||||
Layer poolLayer = new SubsamplingLayer.Builder()
|
LayerConfiguration poolLayer = new SubsamplingLayer.Builder()
|
||||||
.poolingType(SubsamplingLayer.PoolingType.MAX).kernelSize(k, k).dataFormat(format)
|
.poolingType(SubsamplingLayer.PoolingType.MAX).kernelSize(k, k).dataFormat(format)
|
||||||
.stride(stride, stride).padding(0, 0).build();
|
.stride(stride, stride).padding(0, 0).build();
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345)
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().seed(12345)
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.updater(new NoOp())
|
.updater(new NoOp())
|
||||||
.activation(Activation.TANH).convolutionMode(Same).list()
|
.activation(Activation.TANH).convolutionMode(Same).list()
|
||||||
|
@ -825,7 +823,7 @@ public class CNNGradientCheckTest extends BaseDL4JTest {
|
||||||
.layer(1, convFirst ? poolLayer : convLayer)
|
.layer(1, convFirst ? poolLayer : convLayer)
|
||||||
.layer(2, new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
.layer(2, new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
||||||
.activation(Activation.SOFTMAX).nOut(nOut).build())
|
.activation(Activation.SOFTMAX).nOut(nOut).build())
|
||||||
.setInputType(InputType.convolutional(height, width, inputDepth, format))
|
.inputType(InputType.convolutional(height, width, inputDepth, format))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
|
@ -883,8 +881,8 @@ public class CNNGradientCheckTest extends BaseDL4JTest {
|
||||||
INDArray input = Nd4j.rand(DataType.DOUBLE, inShape);
|
INDArray input = Nd4j.rand(DataType.DOUBLE, inShape);
|
||||||
INDArray labels = TestUtils.randomOneHot(minibatchSize, nOut);
|
INDArray labels = TestUtils.randomOneHot(minibatchSize, nOut);
|
||||||
|
|
||||||
MultiLayerConfiguration conf =
|
NeuralNetConfiguration conf =
|
||||||
new NeuralNetConfiguration.Builder().updater(new NoOp())
|
NeuralNetConfiguration.builder().updater(new NoOp())
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.dist(new NormalDistribution(0, 1)).list()
|
.dist(new NormalDistribution(0, 1)).list()
|
||||||
.layer(0, new ConvolutionLayer.Builder(kernel, stride, padding).dataFormat(format)
|
.layer(0, new ConvolutionLayer.Builder(kernel, stride, padding).dataFormat(format)
|
||||||
|
@ -894,7 +892,7 @@ public class CNNGradientCheckTest extends BaseDL4JTest {
|
||||||
padding).nIn(3).nOut(3).dataFormat(format).build())//output: (6-2+0)/1+1 = 5
|
padding).nIn(3).nOut(3).dataFormat(format).build())//output: (6-2+0)/1+1 = 5
|
||||||
.layer(3, new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
.layer(3, new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
||||||
.activation(Activation.SOFTMAX).nOut(4).build())
|
.activation(Activation.SOFTMAX).nOut(4).build())
|
||||||
.setInputType(InputType.convolutional(height, width, inputDepth, format))
|
.inputType(InputType.convolutional(height, width, inputDepth, format))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
|
@ -971,7 +969,7 @@ public class CNNGradientCheckTest extends BaseDL4JTest {
|
||||||
labels.putScalar(new int[]{j, j % nOut}, 1.0);
|
labels.putScalar(new int[]{j, j % nOut}, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
NeuralNetConfiguration.ListBuilder b = new NeuralNetConfiguration.Builder().seed(12345)
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().seed(12345)
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.updater(new NoOp())
|
.updater(new NoOp())
|
||||||
.activation(act)
|
.activation(act)
|
||||||
|
@ -981,11 +979,11 @@ public class CNNGradientCheckTest extends BaseDL4JTest {
|
||||||
.stride(s, s).dataFormat(format)
|
.stride(s, s).dataFormat(format)
|
||||||
.dilation(d, d)
|
.dilation(d, d)
|
||||||
.convolutionMode(cm)
|
.convolutionMode(cm)
|
||||||
.nIn(inputDepth).nOut(nOut).build());
|
.nIn(inputDepth).nOut(nOut).build())
|
||||||
|
|
||||||
MultiLayerConfiguration conf = b.layer(new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
.layer(new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
||||||
.activation(Activation.SOFTMAX).nOut(nOut).build())
|
.activation(Activation.SOFTMAX).nOut(nOut).build())
|
||||||
.setInputType(InputType.convolutional(h, w, inputDepth, format)).build();
|
.inputType(InputType.convolutional(h, w, inputDepth, format)).build();
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
net.init();
|
net.init();
|
||||||
|
@ -1043,7 +1041,7 @@ public class CNNGradientCheckTest extends BaseDL4JTest {
|
||||||
labels.putScalar(new int[]{i, i % nOut}, 1.0);
|
labels.putScalar(new int[]{i, i % nOut}, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
NeuralNetConfiguration.ListBuilder b = new NeuralNetConfiguration.Builder().seed(12345)
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().seed(12345)
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.updater(new NoOp())
|
.updater(new NoOp())
|
||||||
.activation(Activation.TANH)
|
.activation(Activation.TANH)
|
||||||
|
@ -1054,11 +1052,11 @@ public class CNNGradientCheckTest extends BaseDL4JTest {
|
||||||
.stride(s, s)
|
.stride(s, s)
|
||||||
.dilation(d, d)
|
.dilation(d, d)
|
||||||
.depthMultiplier(3).dataFormat(format)
|
.depthMultiplier(3).dataFormat(format)
|
||||||
.nIn(inputDepth).nOut(2).build());
|
.nIn(inputDepth).nOut(2).build())
|
||||||
|
|
||||||
MultiLayerConfiguration conf = b.layer(new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
.layer(new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
||||||
.activation(Activation.SOFTMAX).nOut(nOut).build())
|
.activation(Activation.SOFTMAX).nOut(nOut).build())
|
||||||
.setInputType(InputType.convolutional(h, w, inputDepth, format)).build();
|
.inputType(InputType.convolutional(h, w, inputDepth, format)).build();
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
net.init();
|
net.init();
|
||||||
|
@ -1116,7 +1114,7 @@ public class CNNGradientCheckTest extends BaseDL4JTest {
|
||||||
labels.putScalar(new int[]{i, i % nOut}, 1.0);
|
labels.putScalar(new int[]{i, i % nOut}, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
NeuralNetConfiguration.ListBuilder b = new NeuralNetConfiguration.Builder().seed(12345)
|
NeuralNetConfiguration.NeuralNetConfigurationBuilder b = NeuralNetConfiguration.builder().seed(12345)
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.updater(new NoOp())
|
.updater(new NoOp())
|
||||||
.activation(Activation.TANH).convolutionMode(cm).list()
|
.activation(Activation.TANH).convolutionMode(cm).list()
|
||||||
|
@ -1140,9 +1138,9 @@ public class CNNGradientCheckTest extends BaseDL4JTest {
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiLayerConfiguration conf = b.layer(new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
NeuralNetConfiguration conf = (NeuralNetConfiguration) b.layer(new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
||||||
.activation(Activation.SOFTMAX).nOut(nOut).build())
|
.activation(Activation.SOFTMAX).nOut(nOut).build())
|
||||||
.setInputType(InputType.convolutional(h, w, inputDepth, format)).build();
|
.inputType(InputType.convolutional(h, w, inputDepth, format)).build();
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
net.init();
|
net.init();
|
||||||
|
@ -1190,8 +1188,8 @@ public class CNNGradientCheckTest extends BaseDL4JTest {
|
||||||
INDArray input = Nd4j.rand(DataType.DOUBLE, inShape);
|
INDArray input = Nd4j.rand(DataType.DOUBLE, inShape);
|
||||||
INDArray labels = TestUtils.randomOneHot(minibatchSize, nOut);
|
INDArray labels = TestUtils.randomOneHot(minibatchSize, nOut);
|
||||||
|
|
||||||
MultiLayerConfiguration conf =
|
NeuralNetConfiguration conf =
|
||||||
new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.updater(new NoOp())
|
.updater(new NoOp())
|
||||||
.convolutionMode(ConvolutionMode.Same)
|
.convolutionMode(ConvolutionMode.Same)
|
||||||
|
@ -1208,7 +1206,7 @@ public class CNNGradientCheckTest extends BaseDL4JTest {
|
||||||
.build())
|
.build())
|
||||||
.layer(3, new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
.layer(3, new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
||||||
.activation(Activation.SOFTMAX).nOut(nOut).build())
|
.activation(Activation.SOFTMAX).nOut(nOut).build())
|
||||||
.setInputType(InputType.convolutional(height, width, inputDepth, format))
|
.inputType(InputType.convolutional(height, width, inputDepth, format))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
|
@ -1277,7 +1275,7 @@ public class CNNGradientCheckTest extends BaseDL4JTest {
|
||||||
labels.putScalar(new int[]{i, i % nOut}, 1.0);
|
labels.putScalar(new int[]{i, i % nOut}, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
NeuralNetConfiguration.ListBuilder b = new NeuralNetConfiguration.Builder().seed(12345)
|
NeuralNetConfiguration.NeuralNetConfigurationBuilder b = NeuralNetConfiguration.builder().seed(12345)
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.updater(new NoOp())
|
.updater(new NoOp())
|
||||||
.activation(Activation.TANH)
|
.activation(Activation.TANH)
|
||||||
|
@ -1293,9 +1291,9 @@ public class CNNGradientCheckTest extends BaseDL4JTest {
|
||||||
.depthMultiplier(depthMultiplier)
|
.depthMultiplier(depthMultiplier)
|
||||||
.nIn(nIn).build()); // nOut = nIn * depthMultiplier
|
.nIn(nIn).build()); // nOut = nIn * depthMultiplier
|
||||||
|
|
||||||
MultiLayerConfiguration conf = b.layer(new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
NeuralNetConfiguration conf = (NeuralNetConfiguration) b.layer(new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
||||||
.activation(Activation.SOFTMAX).nOut(nOut).build())
|
.activation(Activation.SOFTMAX).nOut(nOut).build())
|
||||||
.setInputType(InputType.convolutional(height, width, nIn, format)).build();
|
.inputType(InputType.convolutional(height, width, nIn, format)).build();
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
net.init();
|
net.init();
|
||||||
|
|
|
@ -24,7 +24,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
import org.deeplearning4j.BaseDL4JTest;
|
import org.deeplearning4j.BaseDL4JTest;
|
||||||
import org.deeplearning4j.TestUtils;
|
import org.deeplearning4j.TestUtils;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.distribution.UniformDistribution;
|
import org.deeplearning4j.nn.conf.distribution.UniformDistribution;
|
||||||
import org.deeplearning4j.nn.conf.inputs.InputType;
|
import org.deeplearning4j.nn.conf.inputs.InputType;
|
||||||
|
@ -44,8 +43,6 @@ import org.nd4j.linalg.factory.Nd4j;
|
||||||
import org.nd4j.linalg.learning.config.NoOp;
|
import org.nd4j.linalg.learning.config.NoOp;
|
||||||
import org.nd4j.linalg.lossfunctions.impl.LossNegativeLogLikelihood;
|
import org.nd4j.linalg.lossfunctions.impl.LossNegativeLogLikelihood;
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
////@Ignore
|
////@Ignore
|
||||||
public class CapsnetGradientCheckTest extends BaseDL4JTest {
|
public class CapsnetGradientCheckTest extends BaseDL4JTest {
|
||||||
|
|
||||||
|
@ -80,12 +77,11 @@ public class CapsnetGradientCheckTest extends BaseDL4JTest {
|
||||||
labels.putScalar(new int[]{i, i % capsule}, 1.0);
|
labels.putScalar(new int[]{i, i % capsule}, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.seed(123)
|
.seed(123)
|
||||||
.updater(new NoOp())
|
.updater(new NoOp())
|
||||||
.weightInit(new WeightInitDistribution(new UniformDistribution(-6, 6)))
|
.dist(new UniformDistribution(-6, 6))
|
||||||
.list()
|
|
||||||
.layer(new PrimaryCapsules.Builder(primaryCapsDim, primarpCapsChannel)
|
.layer(new PrimaryCapsules.Builder(primaryCapsDim, primarpCapsChannel)
|
||||||
.kernelSize(3, 3)
|
.kernelSize(3, 3)
|
||||||
.stride(2, 2)
|
.stride(2, 2)
|
||||||
|
@ -94,7 +90,7 @@ public class CapsnetGradientCheckTest extends BaseDL4JTest {
|
||||||
.layer(new CapsuleStrengthLayer.Builder().build())
|
.layer(new CapsuleStrengthLayer.Builder().build())
|
||||||
.layer(new ActivationLayer.Builder(new ActivationSoftmax()).build())
|
.layer(new ActivationLayer.Builder(new ActivationSoftmax()).build())
|
||||||
.layer(new LossLayer.Builder(new LossNegativeLogLikelihood()).build())
|
.layer(new LossLayer.Builder(new LossNegativeLogLikelihood()).build())
|
||||||
.setInputType(InputType.convolutional(height, width, inputDepth))
|
.inputType(InputType.convolutional(height, width, inputDepth))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
|
|
|
@ -25,7 +25,6 @@ import org.deeplearning4j.BaseDL4JTest;
|
||||||
import org.deeplearning4j.TestUtils;
|
import org.deeplearning4j.TestUtils;
|
||||||
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.ConvolutionMode;
|
import org.deeplearning4j.nn.conf.ConvolutionMode;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.distribution.NormalDistribution;
|
import org.deeplearning4j.nn.conf.distribution.NormalDistribution;
|
||||||
import org.deeplearning4j.nn.conf.dropout.*;
|
import org.deeplearning4j.nn.conf.dropout.*;
|
||||||
|
@ -92,7 +91,7 @@ public class DropoutGradientCheck extends BaseDL4JTest {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
NeuralNetConfiguration.ListBuilder builder = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration.NeuralNetConfigurationBuilder builder = NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.dist(new NormalDistribution(0,1))
|
.dist(new NormalDistribution(0,1))
|
||||||
.convolutionMode(ConvolutionMode.Same)
|
.convolutionMode(ConvolutionMode.Same)
|
||||||
|
@ -104,18 +103,18 @@ public class DropoutGradientCheck extends BaseDL4JTest {
|
||||||
if(cnn){
|
if(cnn){
|
||||||
builder.layer(new ConvolutionLayer.Builder().kernelSize(3,3).stride(2,2).nOut(2).build());
|
builder.layer(new ConvolutionLayer.Builder().kernelSize(3,3).stride(2,2).nOut(2).build());
|
||||||
builder.layer(new ConvolutionLayer.Builder().kernelSize(3,3).stride(2,2).nOut(2).build());
|
builder.layer(new ConvolutionLayer.Builder().kernelSize(3,3).stride(2,2).nOut(2).build());
|
||||||
builder.setInputType(InputType.convolutional(6,6,2));
|
builder.inputType(InputType.convolutional(6,6,2));
|
||||||
} else {
|
} else {
|
||||||
builder.layer(new DenseLayer.Builder().nOut(3).build());
|
builder.layer(new DenseLayer.Builder().nOut(3).build());
|
||||||
builder.layer(new DenseLayer.Builder().nOut(3).build());
|
builder.layer(new DenseLayer.Builder().nOut(3).build());
|
||||||
builder.setInputType(InputType.feedForward(6));
|
builder.inputType(InputType.feedForward(6));
|
||||||
}
|
}
|
||||||
builder.layer(new OutputLayer.Builder().nOut(3).activation(Activation.SOFTMAX).lossFunction(LossFunction.MCXENT).build());
|
builder.layer(new OutputLayer.Builder().nOut(3).activation(Activation.SOFTMAX).lossFunction(LossFunction.MCXENT).build());
|
||||||
|
|
||||||
MultiLayerConfiguration conf = builder.build();
|
NeuralNetConfiguration conf = builder.build();
|
||||||
//Remove spatial dropout from output layer - can't be used for 2d input
|
//Remove spatial dropout from output layer - can't be used for 2d input
|
||||||
if(i == 4){
|
if(i == 4){
|
||||||
conf.getConf(2).getLayer().setIDropout(null);
|
conf.getFlattenedLayerConfigurations().get(2).setIDropout(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiLayerNetwork mln = new MultiLayerNetwork(conf);
|
MultiLayerNetwork mln = new MultiLayerNetwork(conf);
|
||||||
|
@ -149,7 +148,7 @@ public class DropoutGradientCheck extends BaseDL4JTest {
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
int mb = 3;
|
int mb = 3;
|
||||||
|
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder()
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.dist(new NormalDistribution(0,1))
|
.dist(new NormalDistribution(0,1))
|
||||||
.convolutionMode(ConvolutionMode.Same)
|
.convolutionMode(ConvolutionMode.Same)
|
||||||
|
|
|
@ -24,7 +24,6 @@ import org.deeplearning4j.BaseDL4JTest;
|
||||||
import org.deeplearning4j.TestUtils;
|
import org.deeplearning4j.TestUtils;
|
||||||
import org.deeplearning4j.nn.conf.CNN2DFormat;
|
import org.deeplearning4j.nn.conf.CNN2DFormat;
|
||||||
import org.deeplearning4j.nn.conf.ConvolutionMode;
|
import org.deeplearning4j.nn.conf.ConvolutionMode;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.distribution.NormalDistribution;
|
import org.deeplearning4j.nn.conf.distribution.NormalDistribution;
|
||||||
import org.deeplearning4j.nn.conf.inputs.InputType;
|
import org.deeplearning4j.nn.conf.inputs.InputType;
|
||||||
|
@ -72,7 +71,7 @@ public class GlobalPoolingGradientCheckTests extends BaseDL4JTest {
|
||||||
for (int miniBatchSize : minibatchSizes) {
|
for (int miniBatchSize : minibatchSizes) {
|
||||||
for (PoolingType pt : poolingTypes) {
|
for (PoolingType pt : poolingTypes) {
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.updater(new NoOp())
|
.updater(new NoOp())
|
||||||
.dist(new NormalDistribution(0, 1.0)).seed(12345L).list()
|
.dist(new NormalDistribution(0, 1.0)).seed(12345L).list()
|
||||||
|
@ -127,7 +126,7 @@ public class GlobalPoolingGradientCheckTests extends BaseDL4JTest {
|
||||||
for (int miniBatchSize : minibatchSizes) {
|
for (int miniBatchSize : minibatchSizes) {
|
||||||
for (PoolingType pt : poolingTypes) {
|
for (PoolingType pt : poolingTypes) {
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.updater(new NoOp())
|
.updater(new NoOp())
|
||||||
.dist(new NormalDistribution(0, 1.0)).seed(12345L).list()
|
.dist(new NormalDistribution(0, 1.0)).seed(12345L).list()
|
||||||
|
@ -138,7 +137,7 @@ public class GlobalPoolingGradientCheckTests extends BaseDL4JTest {
|
||||||
.layer(1, new GlobalPoolingLayer.Builder().poolingType(pt).build())
|
.layer(1, new GlobalPoolingLayer.Builder().poolingType(pt).build())
|
||||||
.layer(2, new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
.layer(2, new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
||||||
.activation(Activation.SOFTMAX).nOut(nOut).build())
|
.activation(Activation.SOFTMAX).nOut(nOut).build())
|
||||||
.setInputType(InputType.convolutional(inputH, inputW, inputDepth, nchw ? CNN2DFormat.NCHW : CNN2DFormat.NHWC)).build();
|
.inputType(InputType.convolutional(inputH, inputW, inputDepth, nchw ? CNN2DFormat.NCHW : CNN2DFormat.NHWC)).build();
|
||||||
|
|
||||||
MultiLayerNetwork mln = new MultiLayerNetwork(conf);
|
MultiLayerNetwork mln = new MultiLayerNetwork(conf);
|
||||||
mln.init();
|
mln.init();
|
||||||
|
@ -185,7 +184,7 @@ public class GlobalPoolingGradientCheckTests extends BaseDL4JTest {
|
||||||
|
|
||||||
for (PoolingType pt : poolingTypes) {
|
for (PoolingType pt : poolingTypes) {
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.updater(new NoOp())
|
.updater(new NoOp())
|
||||||
.dist(new NormalDistribution(0, 1.0)).seed(12345L).list()
|
.dist(new NormalDistribution(0, 1.0)).seed(12345L).list()
|
||||||
|
@ -259,7 +258,7 @@ public class GlobalPoolingGradientCheckTests extends BaseDL4JTest {
|
||||||
stride = new int[] {inputH, 1};
|
stride = new int[] {inputH, 1};
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.updater(new NoOp())
|
.updater(new NoOp())
|
||||||
.dist(new NormalDistribution(0, 1.0)).convolutionMode(ConvolutionMode.Same)
|
.dist(new NormalDistribution(0, 1.0)).convolutionMode(ConvolutionMode.Same)
|
||||||
|
@ -270,7 +269,7 @@ public class GlobalPoolingGradientCheckTests extends BaseDL4JTest {
|
||||||
.layer(2, new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
.layer(2, new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
||||||
.activation(Activation.SOFTMAX).nOut(nOut).build())
|
.activation(Activation.SOFTMAX).nOut(nOut).build())
|
||||||
|
|
||||||
.setInputType(InputType.convolutional(inputH, inputW, inputDepth)).build();
|
.inputType(InputType.convolutional(inputH, inputW, inputDepth)).build();
|
||||||
|
|
||||||
MultiLayerNetwork mln = new MultiLayerNetwork(conf);
|
MultiLayerNetwork mln = new MultiLayerNetwork(conf);
|
||||||
mln.init();
|
mln.init();
|
||||||
|
|
|
@ -26,7 +26,6 @@ import org.deeplearning4j.TestUtils;
|
||||||
import org.deeplearning4j.datasets.iterator.impl.IrisDataSetIterator;
|
import org.deeplearning4j.datasets.iterator.impl.IrisDataSetIterator;
|
||||||
import org.deeplearning4j.nn.api.OptimizationAlgorithm;
|
import org.deeplearning4j.nn.api.OptimizationAlgorithm;
|
||||||
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.RNNFormat;
|
import org.deeplearning4j.nn.conf.RNNFormat;
|
||||||
import org.deeplearning4j.nn.conf.distribution.NormalDistribution;
|
import org.deeplearning4j.nn.conf.distribution.NormalDistribution;
|
||||||
|
@ -74,7 +73,7 @@ public class GradientCheckTests extends BaseDL4JTest {
|
||||||
public void testMinibatchApplication() {
|
public void testMinibatchApplication() {
|
||||||
IrisDataSetIterator iter = new IrisDataSetIterator(30, 150);
|
IrisDataSetIterator iter = new IrisDataSetIterator(30, 150);
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().miniBatch(false)
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().miniBatch(false)
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).updater(new NoOp())
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).updater(new NoOp())
|
||||||
.list()
|
.list()
|
||||||
|
@ -164,7 +163,7 @@ public class GradientCheckTests extends BaseDL4JTest {
|
||||||
LossFunction lf = lossFunctions[i];
|
LossFunction lf = lossFunctions[i];
|
||||||
Activation outputActivation = outputActivations[i];
|
Activation outputActivation = outputActivations[i];
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.CONJUGATE_GRADIENT).updater(new NoOp())
|
.optimizationAlgo(OptimizationAlgorithm.CONJUGATE_GRADIENT).updater(new NoOp())
|
||||||
.seed(12345L)
|
.seed(12345L)
|
||||||
|
@ -253,8 +252,8 @@ public class GradientCheckTests extends BaseDL4JTest {
|
||||||
double l2 = l2vals[k];
|
double l2 = l2vals[k];
|
||||||
double l1 = l1vals[k];
|
double l1 = l1vals[k];
|
||||||
|
|
||||||
MultiLayerConfiguration conf =
|
NeuralNetConfiguration conf =
|
||||||
new NeuralNetConfiguration.Builder().l2(l2).l1(l1)
|
NeuralNetConfiguration.builder().l2(l2).l1(l1)
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.l2Bias(biasL2[k]).l1Bias(biasL1[k])
|
.l2Bias(biasL2[k]).l1Bias(biasL1[k])
|
||||||
.optimizationAlgo(OptimizationAlgorithm.CONJUGATE_GRADIENT)
|
.optimizationAlgo(OptimizationAlgorithm.CONJUGATE_GRADIENT)
|
||||||
|
@ -325,7 +324,7 @@ public class GradientCheckTests extends BaseDL4JTest {
|
||||||
labels.putScalar(new int[] {i, r.nextInt(3)}, 1.0);
|
labels.putScalar(new int[] {i, r.nextInt(3)}, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().l2(0.2).l1(0.1)
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().l2(0.2).l1(0.1)
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).seed(12345L)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).seed(12345L)
|
||||||
.list().layer(new EmbeddingLayer.Builder().nIn(4).nOut(3).weightInit(WeightInit.XAVIER)
|
.list().layer(new EmbeddingLayer.Builder().nIn(4).nOut(3).weightInit(WeightInit.XAVIER)
|
||||||
|
@ -363,7 +362,7 @@ public class GradientCheckTests extends BaseDL4JTest {
|
||||||
labels.putScalar(new int[] {i, r.nextInt(3)}, 1.0);
|
labels.putScalar(new int[] {i, r.nextInt(3)}, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().l2(0.2).l1(0.1)
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().l2(0.2).l1(0.1)
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).seed(12345L)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).seed(12345L)
|
||||||
.list().layer(0,
|
.list().layer(0,
|
||||||
|
@ -429,8 +428,8 @@ public class GradientCheckTests extends BaseDL4JTest {
|
||||||
double l1 = l1vals[k];
|
double l1 = l1vals[k];
|
||||||
|
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
MultiLayerConfiguration conf =
|
NeuralNetConfiguration conf =
|
||||||
new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.updater(new NoOp())
|
.updater(new NoOp())
|
||||||
.l2(l2).l1(l1)
|
.l2(l2).l1(l1)
|
||||||
|
@ -491,7 +490,7 @@ public class GradientCheckTests extends BaseDL4JTest {
|
||||||
|
|
||||||
for(Activation a : new Activation[]{Activation.IDENTITY, Activation.TANH}) {
|
for(Activation a : new Activation[]{Activation.IDENTITY, Activation.TANH}) {
|
||||||
|
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder()
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.CONJUGATE_GRADIENT).updater(new NoOp())
|
.optimizationAlgo(OptimizationAlgorithm.CONJUGATE_GRADIENT).updater(new NoOp())
|
||||||
.seed(12345L)
|
.seed(12345L)
|
||||||
|
@ -561,7 +560,7 @@ public class GradientCheckTests extends BaseDL4JTest {
|
||||||
for (boolean maskArray : new boolean[]{false, true}) {
|
for (boolean maskArray : new boolean[]{false, true}) {
|
||||||
for (int inputRank : new int[]{2, 3}) {
|
for (int inputRank : new int[]{2, 3}) {
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.seed(12345)
|
.seed(12345)
|
||||||
.updater(new NoOp())
|
.updater(new NoOp())
|
||||||
|
@ -672,8 +671,8 @@ public class GradientCheckTests extends BaseDL4JTest {
|
||||||
double l2 = l2vals[k];
|
double l2 = l2vals[k];
|
||||||
double l1 = l1vals[k];
|
double l1 = l1vals[k];
|
||||||
|
|
||||||
MultiLayerConfiguration conf =
|
NeuralNetConfiguration conf =
|
||||||
new NeuralNetConfiguration.Builder().l2(l2).l1(l1)
|
NeuralNetConfiguration.builder().l2(l2).l1(l1)
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.l2Bias(biasL2[k]).l1Bias(biasL1[k])
|
.l2Bias(biasL2[k]).l1Bias(biasL1[k])
|
||||||
.weightDecay(wdVals[k]).weightDecayBias(wdBias[k])
|
.weightDecay(wdVals[k]).weightDecayBias(wdBias[k])
|
||||||
|
@ -736,7 +735,7 @@ public class GradientCheckTests extends BaseDL4JTest {
|
||||||
LossFunction lf = lossFunctions[i];
|
LossFunction lf = lossFunctions[i];
|
||||||
Activation outputActivation = outputActivations[i];
|
Activation outputActivation = outputActivations[i];
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.CONJUGATE_GRADIENT).updater(new NoOp())
|
.optimizationAlgo(OptimizationAlgorithm.CONJUGATE_GRADIENT).updater(new NoOp())
|
||||||
.seed(12345L)
|
.seed(12345L)
|
||||||
|
|
|
@ -36,9 +36,6 @@ import org.deeplearning4j.nn.conf.graph.rnn.ReverseTimeSeriesVertex;
|
||||||
import org.deeplearning4j.nn.conf.inputs.InputType;
|
import org.deeplearning4j.nn.conf.inputs.InputType;
|
||||||
import org.deeplearning4j.nn.conf.layers.*;
|
import org.deeplearning4j.nn.conf.layers.*;
|
||||||
import org.deeplearning4j.nn.conf.layers.recurrent.SimpleRnn;
|
import org.deeplearning4j.nn.conf.layers.recurrent.SimpleRnn;
|
||||||
import org.deeplearning4j.nn.conf.preprocessor.CnnToFeedForwardPreProcessor;
|
|
||||||
import org.deeplearning4j.nn.conf.preprocessor.FeedForwardToRnnPreProcessor;
|
|
||||||
import org.deeplearning4j.nn.conf.preprocessor.RnnToFeedForwardPreProcessor;
|
|
||||||
import org.deeplearning4j.nn.graph.ComputationGraph;
|
import org.deeplearning4j.nn.graph.ComputationGraph;
|
||||||
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
|
||||||
import org.deeplearning4j.nn.weights.WeightInit;
|
import org.deeplearning4j.nn.weights.WeightInit;
|
||||||
|
@ -52,7 +49,6 @@ import org.nd4j.linalg.indexing.NDArrayIndex;
|
||||||
import org.nd4j.linalg.learning.config.NoOp;
|
import org.nd4j.linalg.learning.config.NoOp;
|
||||||
import org.nd4j.linalg.lossfunctions.LossFunctions;
|
import org.nd4j.linalg.lossfunctions.LossFunctions;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
@ -74,7 +70,7 @@ public class GradientCheckTestsComputationGraph extends BaseDL4JTest {
|
||||||
@Test
|
@Test
|
||||||
public void testBasicIris() {
|
public void testBasicIris() {
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345)
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder().seed(12345)
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.dist(new NormalDistribution(0, 1)).updater(new NoOp())
|
.dist(new NormalDistribution(0, 1)).updater(new NoOp())
|
||||||
|
@ -120,7 +116,7 @@ public class GradientCheckTestsComputationGraph extends BaseDL4JTest {
|
||||||
@Test
|
@Test
|
||||||
public void testBasicIrisWithMerging() {
|
public void testBasicIrisWithMerging() {
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345)
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder().seed(12345)
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.dist(new NormalDistribution(0, 1)).updater(new NoOp())
|
.dist(new NormalDistribution(0, 1)).updater(new NoOp())
|
||||||
|
@ -177,7 +173,7 @@ public class GradientCheckTestsComputationGraph extends BaseDL4JTest {
|
||||||
for (ElementWiseVertex.Op op : ops) {
|
for (ElementWiseVertex.Op op : ops) {
|
||||||
|
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345)
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder().seed(12345)
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.dist(new NormalDistribution(0, 1))
|
.dist(new NormalDistribution(0, 1))
|
||||||
|
@ -235,7 +231,7 @@ public class GradientCheckTestsComputationGraph extends BaseDL4JTest {
|
||||||
for (ElementWiseVertex.Op op : ops) {
|
for (ElementWiseVertex.Op op : ops) {
|
||||||
|
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345)
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder().seed(12345)
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.dist(new NormalDistribution(0, 1))
|
.dist(new NormalDistribution(0, 1))
|
||||||
|
@ -295,7 +291,7 @@ public class GradientCheckTestsComputationGraph extends BaseDL4JTest {
|
||||||
|
|
||||||
for(boolean firstSmaller : new boolean[]{false, true}) {
|
for(boolean firstSmaller : new boolean[]{false, true}) {
|
||||||
for (ElementWiseVertex.Op op : ops) {
|
for (ElementWiseVertex.Op op : ops) {
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder()
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.updater(new NoOp())
|
.updater(new NoOp())
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.activation(Activation.TANH)
|
.activation(Activation.TANH)
|
||||||
|
@ -343,7 +339,7 @@ public class GradientCheckTestsComputationGraph extends BaseDL4JTest {
|
||||||
String msg = "testCnnDepthMerge - " + format;
|
String msg = "testCnnDepthMerge - " + format;
|
||||||
|
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345)
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder().seed(12345)
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.dist(new NormalDistribution(0, 0.1))
|
.dist(new NormalDistribution(0, 0.1))
|
||||||
|
@ -398,7 +394,7 @@ public class GradientCheckTestsComputationGraph extends BaseDL4JTest {
|
||||||
int outSize = 3;
|
int outSize = 3;
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
ComputationGraphConfiguration conf =
|
ComputationGraphConfiguration conf =
|
||||||
new NeuralNetConfiguration.Builder().seed(12345)
|
NeuralNetConfiguration.builder().seed(12345)
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.dist(new UniformDistribution(0.2, 0.6))
|
.dist(new UniformDistribution(0.2, 0.6))
|
||||||
|
@ -457,7 +453,7 @@ public class GradientCheckTestsComputationGraph extends BaseDL4JTest {
|
||||||
int batchSize = 2;
|
int batchSize = 2;
|
||||||
int timeSeriesLength = 4;
|
int timeSeriesLength = 4;
|
||||||
int inLength = 3;
|
int inLength = 3;
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().seed(1234)
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder().seed(1234)
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.weightInit(new NormalDistribution(0, 1))
|
.weightInit(new NormalDistribution(0, 1))
|
||||||
.updater(new NoOp()).graphBuilder().addInputs("input").setOutputs("out")
|
.updater(new NoOp()).graphBuilder().addInputs("input").setOutputs("out")
|
||||||
|
@ -493,7 +489,7 @@ public class GradientCheckTestsComputationGraph extends BaseDL4JTest {
|
||||||
public void testLSTMWithLastTimeStepVertex() {
|
public void testLSTMWithLastTimeStepVertex() {
|
||||||
|
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345)
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder().seed(12345)
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.dist(new NormalDistribution(0, 1))
|
.dist(new NormalDistribution(0, 1))
|
||||||
|
@ -545,7 +541,7 @@ public class GradientCheckTestsComputationGraph extends BaseDL4JTest {
|
||||||
int timeSeriesLength = 4;
|
int timeSeriesLength = 4;
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
ComputationGraphConfiguration conf =
|
ComputationGraphConfiguration conf =
|
||||||
new NeuralNetConfiguration.Builder().seed(12345)
|
NeuralNetConfiguration.builder().seed(12345)
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.dist(new NormalDistribution(0, 1))
|
.dist(new NormalDistribution(0, 1))
|
||||||
|
@ -595,7 +591,7 @@ public class GradientCheckTestsComputationGraph extends BaseDL4JTest {
|
||||||
int timeSeriesLength = 4;
|
int timeSeriesLength = 4;
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
ComputationGraphConfiguration conf =
|
ComputationGraphConfiguration conf =
|
||||||
new NeuralNetConfiguration.Builder().seed(12345)
|
NeuralNetConfiguration.builder().seed(12345)
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.dist(new NormalDistribution(0, 1))
|
.dist(new NormalDistribution(0, 1))
|
||||||
|
@ -654,7 +650,7 @@ public class GradientCheckTestsComputationGraph extends BaseDL4JTest {
|
||||||
public void testMultipleInputsLayer() {
|
public void testMultipleInputsLayer() {
|
||||||
|
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345)
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder().seed(12345)
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.dist(new NormalDistribution(0, 1))
|
.dist(new NormalDistribution(0, 1))
|
||||||
|
@ -697,7 +693,7 @@ public class GradientCheckTestsComputationGraph extends BaseDL4JTest {
|
||||||
@Test
|
@Test
|
||||||
public void testMultipleOutputsLayer() {
|
public void testMultipleOutputsLayer() {
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345)
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder().seed(12345)
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.dist(new NormalDistribution(0, 1))
|
.dist(new NormalDistribution(0, 1))
|
||||||
|
@ -737,7 +733,7 @@ public class GradientCheckTestsComputationGraph extends BaseDL4JTest {
|
||||||
@Test
|
@Test
|
||||||
public void testMultipleOutputsMergeVertex() {
|
public void testMultipleOutputsMergeVertex() {
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345)
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder().seed(12345)
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.dist(new NormalDistribution(0, 1))
|
.dist(new NormalDistribution(0, 1))
|
||||||
|
@ -786,7 +782,7 @@ public class GradientCheckTestsComputationGraph extends BaseDL4JTest {
|
||||||
int inW = 7;
|
int inW = 7;
|
||||||
|
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345)
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder().seed(12345)
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.dist(new NormalDistribution(0, 1))
|
.dist(new NormalDistribution(0, 1))
|
||||||
|
@ -836,7 +832,7 @@ public class GradientCheckTestsComputationGraph extends BaseDL4JTest {
|
||||||
public void testBasicIrisTripletStackingL2Loss() {
|
public void testBasicIrisTripletStackingL2Loss() {
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
ComputationGraphConfiguration conf =
|
ComputationGraphConfiguration conf =
|
||||||
new NeuralNetConfiguration.Builder().seed(12345)
|
NeuralNetConfiguration.builder().seed(12345)
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.dist(new NormalDistribution(0, 1))
|
.dist(new NormalDistribution(0, 1))
|
||||||
|
@ -910,7 +906,7 @@ public class GradientCheckTestsComputationGraph extends BaseDL4JTest {
|
||||||
for (boolean train : trainFirst) {
|
for (boolean train : trainFirst) {
|
||||||
for (double lambda : new double[] {0.0, 0.5, 2.0}) {
|
for (double lambda : new double[] {0.0, 0.5, 2.0}) {
|
||||||
|
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345)
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder().seed(12345)
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.dist(new GaussianDistribution(0, 1))
|
.dist(new GaussianDistribution(0, 1))
|
||||||
|
@ -975,7 +971,7 @@ public class GradientCheckTestsComputationGraph extends BaseDL4JTest {
|
||||||
for (boolean train : trainFirst) {
|
for (boolean train : trainFirst) {
|
||||||
for (double lambda : new double[] {0.0, 0.5, 2.0}) {
|
for (double lambda : new double[] {0.0, 0.5, 2.0}) {
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.updater(new NoOp())
|
.updater(new NoOp())
|
||||||
.dist(new NormalDistribution(0, 1.0)).seed(12345L).list()
|
.dist(new NormalDistribution(0, 1.0)).seed(12345L).list()
|
||||||
|
@ -986,7 +982,7 @@ public class GradientCheckTestsComputationGraph extends BaseDL4JTest {
|
||||||
.alpha(1.0).lambda(lambda).gradientCheck(true)
|
.alpha(1.0).lambda(lambda).gradientCheck(true)
|
||||||
.activation(Activation.SOFTMAX).build())
|
.activation(Activation.SOFTMAX).build())
|
||||||
|
|
||||||
.setInputType(InputType.convolutional(inputH, inputW, inputDepth)).build();
|
.inputType(InputType.convolutional(inputH, inputW, inputDepth)).build();
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
net.init();
|
net.init();
|
||||||
|
@ -1029,7 +1025,7 @@ public class GradientCheckTestsComputationGraph extends BaseDL4JTest {
|
||||||
@Test
|
@Test
|
||||||
public void testBasicL2() {
|
public void testBasicL2() {
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345)
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder().seed(12345)
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.dist(new NormalDistribution(0, 1))
|
.dist(new NormalDistribution(0, 1))
|
||||||
|
@ -1081,7 +1077,7 @@ public class GradientCheckTestsComputationGraph extends BaseDL4JTest {
|
||||||
int layerSizes = 2;
|
int layerSizes = 2;
|
||||||
|
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345)
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder().seed(12345)
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.dist(new NormalDistribution(0, 1))
|
.dist(new NormalDistribution(0, 1))
|
||||||
|
@ -1136,7 +1132,7 @@ public class GradientCheckTestsComputationGraph extends BaseDL4JTest {
|
||||||
public void testBasicStackUnstackDebug() {
|
public void testBasicStackUnstackDebug() {
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
|
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345)
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder().seed(12345)
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.dist(new NormalDistribution(0, 1))
|
.dist(new NormalDistribution(0, 1))
|
||||||
|
@ -1196,7 +1192,7 @@ public class GradientCheckTestsComputationGraph extends BaseDL4JTest {
|
||||||
int layerSizes = 2;
|
int layerSizes = 2;
|
||||||
|
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345)
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder().seed(12345)
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.dist(new NormalDistribution(0, 1))
|
.dist(new NormalDistribution(0, 1))
|
||||||
|
@ -1259,7 +1255,7 @@ public class GradientCheckTestsComputationGraph extends BaseDL4JTest {
|
||||||
public void testBasicTwoOutputs() {
|
public void testBasicTwoOutputs() {
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
|
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345)
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder().seed(12345)
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.dist(new NormalDistribution(0, 1))
|
.dist(new NormalDistribution(0, 1))
|
||||||
|
@ -1320,7 +1316,7 @@ public class GradientCheckTestsComputationGraph extends BaseDL4JTest {
|
||||||
int[][] definitions = {null,new int[]{1}};
|
int[][] definitions = {null,new int[]{1}};
|
||||||
for(int[] definition : definitions) {
|
for(int[] definition : definitions) {
|
||||||
log.info("Testing definition {}",definition);
|
log.info("Testing definition {}",definition);
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345)
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder().seed(12345)
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.activation(Activation.TANH).updater(new NoOp()).graphBuilder()
|
.activation(Activation.TANH).updater(new NoOp()).graphBuilder()
|
||||||
|
@ -1368,7 +1364,7 @@ public class GradientCheckTestsComputationGraph extends BaseDL4JTest {
|
||||||
int w = 4;
|
int w = 4;
|
||||||
int dIn = 2;
|
int dIn = 2;
|
||||||
|
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345)
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder().seed(12345)
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)
|
||||||
.dist(new NormalDistribution(0, 1))
|
.dist(new NormalDistribution(0, 1))
|
||||||
|
@ -1420,7 +1416,7 @@ public class GradientCheckTestsComputationGraph extends BaseDL4JTest {
|
||||||
labels.putScalar(new int[] {i, r.nextInt(3)}, 1.0);
|
labels.putScalar(new int[] {i, r.nextInt(3)}, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().l2(0.2).l1(0.1)
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder().l2(0.2).l1(0.1)
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).seed(12345L)
|
.optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT).seed(12345L)
|
||||||
.updater(new NoOp()).graphBuilder().addInputs("in")
|
.updater(new NoOp()).graphBuilder().addInputs("in")
|
||||||
|
|
|
@ -24,7 +24,6 @@ import lombok.val;
|
||||||
import org.deeplearning4j.BaseDL4JTest;
|
import org.deeplearning4j.BaseDL4JTest;
|
||||||
import org.deeplearning4j.TestUtils;
|
import org.deeplearning4j.TestUtils;
|
||||||
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
import org.deeplearning4j.nn.conf.ComputationGraphConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
import org.deeplearning4j.nn.conf.RNNFormat;
|
import org.deeplearning4j.nn.conf.RNNFormat;
|
||||||
import org.deeplearning4j.nn.conf.distribution.NormalDistribution;
|
import org.deeplearning4j.nn.conf.distribution.NormalDistribution;
|
||||||
|
@ -117,7 +116,7 @@ public class GradientCheckTestsMasking extends BaseDL4JTest {
|
||||||
maskArr.putScalar(new int[] {0, j}, mask[i][j] ? 1.0 : 0.0);
|
maskArr.putScalar(new int[] {0, j}, mask[i][j] ? 1.0 : 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().seed(12345L)
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().seed(12345L)
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.updater(new NoOp())
|
.updater(new NoOp())
|
||||||
.list()
|
.list()
|
||||||
|
@ -158,7 +157,7 @@ public class GradientCheckTestsMasking extends BaseDL4JTest {
|
||||||
int testNum = 0;
|
int testNum = 0;
|
||||||
for (INDArray mask : masks) {
|
for (INDArray mask : masks) {
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.updater(new NoOp())
|
.updater(new NoOp())
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.dist(new NormalDistribution(0, 1.0)).seed(12345L).list()
|
.dist(new NormalDistribution(0, 1.0)).seed(12345L).list()
|
||||||
|
@ -238,7 +237,7 @@ public class GradientCheckTestsMasking extends BaseDL4JTest {
|
||||||
Activation a = act[i];
|
Activation a = act[i];
|
||||||
|
|
||||||
|
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().updater(new NoOp())
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().updater(new NoOp())
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.dist(new NormalDistribution(0, 1)).seed(12345)
|
.dist(new NormalDistribution(0, 1)).seed(12345)
|
||||||
.list()
|
.list()
|
||||||
|
@ -332,7 +331,7 @@ public class GradientCheckTestsMasking extends BaseDL4JTest {
|
||||||
Activation a = act[i];
|
Activation a = act[i];
|
||||||
|
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().updater(new NoOp())
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder().updater(new NoOp())
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.dist(new NormalDistribution(0, 1)).seed(12345)
|
.dist(new NormalDistribution(0, 1)).seed(12345)
|
||||||
.list()
|
.list()
|
||||||
|
@ -341,7 +340,7 @@ public class GradientCheckTestsMasking extends BaseDL4JTest {
|
||||||
.layer(1, new RnnOutputLayer.Builder().nIn(layerSize).nOut(nOut).lossFunction(lf)
|
.layer(1, new RnnOutputLayer.Builder().nIn(layerSize).nOut(nOut).lossFunction(lf)
|
||||||
.activation(a).build())
|
.activation(a).build())
|
||||||
.validateOutputLayerConfig(false)
|
.validateOutputLayerConfig(false)
|
||||||
.setInputType(InputType.recurrent(nIn,tsLength, RNNFormat.NCW))
|
.inputType(InputType.recurrent(nIn,tsLength, RNNFormat.NCW))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
|
@ -365,7 +364,7 @@ public class GradientCheckTestsMasking extends BaseDL4JTest {
|
||||||
|
|
||||||
//Check the equivalent compgraph:
|
//Check the equivalent compgraph:
|
||||||
Nd4j.getRandom().setSeed(12345);
|
Nd4j.getRandom().setSeed(12345);
|
||||||
ComputationGraphConfiguration cg = new NeuralNetConfiguration.Builder().updater(new NoOp())
|
ComputationGraphConfiguration cg = NeuralNetConfiguration.builder().updater(new NoOp())
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.dist(new NormalDistribution(0, 2)).seed(12345)
|
.dist(new NormalDistribution(0, 2)).seed(12345)
|
||||||
.graphBuilder().addInputs("in")
|
.graphBuilder().addInputs("in")
|
||||||
|
@ -397,7 +396,7 @@ public class GradientCheckTestsMasking extends BaseDL4JTest {
|
||||||
|
|
||||||
int mb = 4;
|
int mb = 4;
|
||||||
int tsLength = 5;
|
int tsLength = 5;
|
||||||
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder()
|
NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.weightInit(new NormalDistribution(0,2))
|
.weightInit(new NormalDistribution(0,2))
|
||||||
.updater(new NoOp())
|
.updater(new NoOp())
|
||||||
|
@ -405,7 +404,7 @@ public class GradientCheckTestsMasking extends BaseDL4JTest {
|
||||||
.layer(new LSTM.Builder().nIn(3).nOut(3).build())
|
.layer(new LSTM.Builder().nIn(3).nOut(3).build())
|
||||||
.layer(new GlobalPoolingLayer.Builder().poolingType(PoolingType.AVG).build())
|
.layer(new GlobalPoolingLayer.Builder().poolingType(PoolingType.AVG).build())
|
||||||
.layer(new OutputLayer.Builder().nIn(3).nOut(3).activation(Activation.SOFTMAX).build())
|
.layer(new OutputLayer.Builder().nIn(3).nOut(3).activation(Activation.SOFTMAX).build())
|
||||||
.setInputType(InputType.recurrent(3))
|
.inputType(InputType.recurrent(3))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
MultiLayerNetwork net = new MultiLayerNetwork(conf);
|
||||||
|
@ -452,7 +451,7 @@ public class GradientCheckTestsMasking extends BaseDL4JTest {
|
||||||
|
|
||||||
int mb = 10;
|
int mb = 10;
|
||||||
int tsLength = 5;
|
int tsLength = 5;
|
||||||
ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder()
|
ComputationGraphConfiguration conf = NeuralNetConfiguration.builder()
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.weightInit(new NormalDistribution(0,2))
|
.weightInit(new NormalDistribution(0,2))
|
||||||
.updater(new NoOp())
|
.updater(new NoOp())
|
||||||
|
|
|
@ -22,8 +22,8 @@ package org.deeplearning4j.gradientcheck;
|
||||||
|
|
||||||
import org.deeplearning4j.BaseDL4JTest;
|
import org.deeplearning4j.BaseDL4JTest;
|
||||||
import org.deeplearning4j.TestUtils;
|
import org.deeplearning4j.TestUtils;
|
||||||
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
|
|
||||||
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
|
||||||
|
import org.deeplearning4j.nn.conf.NeuralNetConfiguration.NeuralNetConfigurationBuilder;
|
||||||
import org.deeplearning4j.nn.conf.distribution.NormalDistribution;
|
import org.deeplearning4j.nn.conf.distribution.NormalDistribution;
|
||||||
import org.deeplearning4j.nn.conf.inputs.InputType;
|
import org.deeplearning4j.nn.conf.inputs.InputType;
|
||||||
import org.deeplearning4j.nn.conf.layers.ConvolutionLayer;
|
import org.deeplearning4j.nn.conf.layers.ConvolutionLayer;
|
||||||
|
@ -68,7 +68,7 @@ public class LRNGradientCheckTests extends BaseDL4JTest {
|
||||||
labels.putScalar(i, r.nextInt(nOut), 1.0);
|
labels.putScalar(i, r.nextInt(nOut), 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiLayerConfiguration.Builder builder = new NeuralNetConfiguration.Builder().updater(new NoOp())
|
NeuralNetConfiguration.NeuralNetConfigurationBuilder builder = NeuralNetConfiguration.builder().updater(new NoOp())
|
||||||
.dataType(DataType.DOUBLE)
|
.dataType(DataType.DOUBLE)
|
||||||
.seed(12345L)
|
.seed(12345L)
|
||||||
.dist(new NormalDistribution(0, 2)).list()
|
.dist(new NormalDistribution(0, 2)).list()
|
||||||
|
@ -77,7 +77,7 @@ public class LRNGradientCheckTests extends BaseDL4JTest {
|
||||||
.layer(1, new LocalResponseNormalization.Builder().build())
|
.layer(1, new LocalResponseNormalization.Builder().build())
|
||||||
.layer(2, new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
.layer(2, new OutputLayer.Builder(LossFunctions.LossFunction.MCXENT)
|
||||||
.activation(Activation.SOFTMAX).nOut(nOut).build())
|
.activation(Activation.SOFTMAX).nOut(nOut).build())
|
||||||
.setInputType(InputType.convolutional(hw, hw, depth));
|
.inputType(InputType.convolutional(hw, hw, depth));
|
||||||
|
|
||||||
MultiLayerNetwork mln = new MultiLayerNetwork(builder.build());
|
MultiLayerNetwork mln = new MultiLayerNetwork(builder.build());
|
||||||
mln.init();
|
mln.init();
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue