From ca4aee16ec19dad375585029ec0188aadc67ae95 Mon Sep 17 00:00:00 2001 From: Alexei KLENIN Date: Sat, 24 Oct 2020 16:01:09 -0700 Subject: [PATCH] FIX: forgotten imports (#9113) Signed-off-by: hosuaby --- .../arbiter/BaseNetworkSpace.java | 11 ++++++- .../multilayernetwork/TestLayerSpace.java | 29 ++++++++++++------- .../TestMultiLayerSpace.java | 11 ++++++- .../async/a3c/discrete/A3CThreadDiscrete.java | 1 + 4 files changed, 40 insertions(+), 12 deletions(-) diff --git a/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/BaseNetworkSpace.java b/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/BaseNetworkSpace.java index 7e8962505..c7d8ccb05 100644 --- a/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/BaseNetworkSpace.java +++ b/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/BaseNetworkSpace.java @@ -31,6 +31,11 @@ import org.deeplearning4j.arbiter.optimize.serde.jackson.YamlMapper; import org.deeplearning4j.earlystopping.EarlyStoppingConfiguration; import org.deeplearning4j.nn.api.OptimizationAlgorithm; import org.deeplearning4j.nn.api.layers.LayerConstraint; +import org.deeplearning4j.nn.conf.BackpropType; +import org.deeplearning4j.nn.conf.ConvolutionMode; +import org.deeplearning4j.nn.conf.GradientNormalization; +import org.deeplearning4j.nn.conf.InputPreProcessor; +import org.deeplearning4j.nn.conf.NeuralNetConfiguration; import org.deeplearning4j.nn.conf.distribution.Distribution; import org.deeplearning4j.nn.conf.dropout.Dropout; import org.deeplearning4j.nn.conf.dropout.IDropout; @@ -43,7 +48,11 @@ import org.nd4j.linalg.learning.config.IUpdater; import org.nd4j.shade.jackson.annotation.JsonTypeInfo; import org.nd4j.shade.jackson.core.JsonProcessingException; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; /** * This is an abstract ParameterSpace for both MultiLayerNetworks (MultiLayerSpace) and ComputationGraph (ComputationGraphSpace) diff --git a/arbiter/arbiter-deeplearning4j/src/test/java/org/deeplearning4j/arbiter/multilayernetwork/TestLayerSpace.java b/arbiter/arbiter-deeplearning4j/src/test/java/org/deeplearning4j/arbiter/multilayernetwork/TestLayerSpace.java index 580799b36..d331f1cda 100644 --- a/arbiter/arbiter-deeplearning4j/src/test/java/org/deeplearning4j/arbiter/multilayernetwork/TestLayerSpace.java +++ b/arbiter/arbiter-deeplearning4j/src/test/java/org/deeplearning4j/arbiter/multilayernetwork/TestLayerSpace.java @@ -16,11 +16,21 @@ package org.deeplearning4j.arbiter.multilayernetwork; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.apache.commons.lang3.ArrayUtils; import org.deeplearning4j.BaseDL4JTest; import org.deeplearning4j.arbiter.TestUtils; import org.deeplearning4j.arbiter.conf.updater.SgdSpace; -import org.deeplearning4j.arbiter.layers.*; +import org.deeplearning4j.arbiter.layers.ActivationLayerSpace; +import org.deeplearning4j.arbiter.layers.BatchNormalizationSpace; +import org.deeplearning4j.arbiter.layers.ConvolutionLayerSpace; +import org.deeplearning4j.arbiter.layers.Deconvolution2DLayerSpace; +import org.deeplearning4j.arbiter.layers.DenseLayerSpace; +import org.deeplearning4j.arbiter.layers.EmbeddingLayerSpace; +import org.deeplearning4j.arbiter.layers.GravesBidirectionalLSTMLayerSpace; import org.deeplearning4j.arbiter.optimize.api.ParameterSpace; import org.deeplearning4j.arbiter.optimize.parameter.BooleanSpace; import org.deeplearning4j.arbiter.optimize.parameter.continuous.ContinuousParameterSpace; @@ -31,6 +41,14 @@ import org.deeplearning4j.nn.conf.constraint.MaxNormConstraint; import org.deeplearning4j.nn.conf.constraint.MinMaxNormConstraint; import org.deeplearning4j.nn.conf.constraint.NonNegativeConstraint; import org.deeplearning4j.nn.conf.constraint.UnitNormConstraint; +import org.deeplearning4j.nn.conf.layers.ActivationLayer; +import org.deeplearning4j.nn.conf.layers.BatchNormalization; +import org.deeplearning4j.nn.conf.layers.Convolution2D; +import org.deeplearning4j.nn.conf.layers.ConvolutionLayer; +import org.deeplearning4j.nn.conf.layers.Deconvolution2D; +import org.deeplearning4j.nn.conf.layers.DenseLayer; +import org.deeplearning4j.nn.conf.layers.EmbeddingLayer; +import org.deeplearning4j.nn.conf.layers.GravesBidirectionalLSTM; import org.junit.Test; import org.nd4j.linalg.activations.Activation; import org.nd4j.linalg.activations.IActivation; @@ -41,13 +59,10 @@ import java.util.Collections; import java.util.List; import java.util.Random; -import static org.junit.Assert.*; - public class TestLayerSpace extends BaseDL4JTest { @Test public void testBasic1() { - DenseLayer expected = new DenseLayer.Builder().nOut(13).activation(Activation.RELU).build(); DenseLayerSpace space = new DenseLayerSpace.Builder().nOut(13).activation(Activation.RELU).build(); @@ -188,8 +203,6 @@ public class TestLayerSpace extends BaseDL4JTest { ActivationLayer al = als.getValue(d); IActivation activation = al.getActivationFn(); -// System.out.println(activation); - assertTrue(containsActivationFunction(actFns, activation)); } } @@ -226,8 +239,6 @@ public class TestLayerSpace extends BaseDL4JTest { IActivation activation = el.getActivationFn(); long nOut = el.getNOut(); -// System.out.println(activation + "\t" + nOut); - assertTrue(containsActivationFunction(actFns, activation)); assertTrue(nOut >= 10 && nOut <= 20); } @@ -293,8 +304,6 @@ public class TestLayerSpace extends BaseDL4JTest { long nOut = el.getNOut(); double forgetGate = el.getForgetGateBiasInit(); -// System.out.println(activation + "\t" + nOut + "\t" + forgetGate); - assertTrue(containsActivationFunction(actFns, activation)); assertTrue(nOut >= 10 && nOut <= 20); assertTrue(forgetGate >= 0.5 && forgetGate <= 0.8); diff --git a/arbiter/arbiter-deeplearning4j/src/test/java/org/deeplearning4j/arbiter/multilayernetwork/TestMultiLayerSpace.java b/arbiter/arbiter-deeplearning4j/src/test/java/org/deeplearning4j/arbiter/multilayernetwork/TestMultiLayerSpace.java index c6ef52628..78497ef8d 100644 --- a/arbiter/arbiter-deeplearning4j/src/test/java/org/deeplearning4j/arbiter/multilayernetwork/TestMultiLayerSpace.java +++ b/arbiter/arbiter-deeplearning4j/src/test/java/org/deeplearning4j/arbiter/multilayernetwork/TestMultiLayerSpace.java @@ -56,6 +56,16 @@ import org.deeplearning4j.nn.conf.constraint.UnitNormConstraint; import org.deeplearning4j.nn.conf.dropout.Dropout; import org.deeplearning4j.nn.conf.dropout.IDropout; import org.deeplearning4j.nn.conf.inputs.InputType; +import org.deeplearning4j.nn.conf.layers.BaseLayer; +import org.deeplearning4j.nn.conf.layers.ConvolutionLayer; +import org.deeplearning4j.nn.conf.layers.DenseLayer; +import org.deeplearning4j.nn.conf.layers.FeedForwardLayer; +import org.deeplearning4j.nn.conf.layers.GlobalPoolingLayer; +import org.deeplearning4j.nn.conf.layers.GravesLSTM; +import org.deeplearning4j.nn.conf.layers.LSTM; +import org.deeplearning4j.nn.conf.layers.OutputLayer; +import org.deeplearning4j.nn.conf.layers.PoolingType; +import org.deeplearning4j.nn.conf.layers.SubsamplingLayer; import org.deeplearning4j.nn.conf.layers.variational.BernoulliReconstructionDistribution; import org.deeplearning4j.nn.conf.layers.variational.GaussianReconstructionDistribution; import org.deeplearning4j.nn.conf.layers.variational.ReconstructionDistribution; @@ -809,7 +819,6 @@ public class TestMultiLayerSpace extends BaseDL4JTest { Candidate conf = candidateGenerator.getCandidate(); MultiLayerConfiguration mlc = conf.getValue().getMultiLayerConfiguration(); FeedForwardLayer ffl = ((FeedForwardLayer) mlc.getConf(0).getLayer()); -// System.out.println(ffl.getIUpdater() + ", " + ffl.getNOut()); actCandidates.add(new Pair<>(ffl.getIUpdater().getLearningRate(0,0), (int)ffl.getNOut())); } diff --git a/rl4j/rl4j-core/src/main/java/org/deeplearning4j/rl4j/learning/async/a3c/discrete/A3CThreadDiscrete.java b/rl4j/rl4j-core/src/main/java/org/deeplearning4j/rl4j/learning/async/a3c/discrete/A3CThreadDiscrete.java index ed9b9c6c0..2283576f5 100644 --- a/rl4j/rl4j-core/src/main/java/org/deeplearning4j/rl4j/learning/async/a3c/discrete/A3CThreadDiscrete.java +++ b/rl4j/rl4j-core/src/main/java/org/deeplearning4j/rl4j/learning/async/a3c/discrete/A3CThreadDiscrete.java @@ -27,6 +27,7 @@ import org.deeplearning4j.rl4j.space.Encodable; import org.deeplearning4j.rl4j.policy.ACPolicy; import org.deeplearning4j.rl4j.policy.Policy; import org.deeplearning4j.rl4j.space.DiscreteSpace; +import org.nd4j.linalg.api.rng.Random; import org.nd4j.linalg.factory.Nd4j; /**