From 0a865f6ee3d9fdd8b956a9ad46a71b5fb939b2ed Mon Sep 17 00:00:00 2001 From: dariuszzbyrad Date: Wed, 29 Jul 2020 13:33:46 +0200 Subject: [PATCH] performance improvement (#9055) * performance improvement Signed-off-by: Dariusz Zbyrad * revert some changes Signed-off-by: Dariusz Zbyrad --- .../arbiter/optimize/api/CandidateGenerator.java | 3 --- .../optimize/config/OptimizationConfiguration.java | 1 - .../distribution/DegenerateIntegerDistribution.java | 5 +++-- .../parameter/continuous/ContinuousParameterSpace.java | 1 - .../parameter/discrete/DiscreteParameterSpace.java | 1 - .../arbiter/optimize/runner/BaseOptimizationRunner.java | 7 ++----- .../genetic/mutation/RandomMutationOperatorTests.java | 1 - .../java/org/deeplearning4j/arbiter/BaseNetworkSpace.java | 8 ++++---- .../deeplearning4j/arbiter/conf/updater/AdaGradSpace.java | 6 ------ .../arbiter/conf/updater/BaseUpdaterSpace.java | 2 -- .../conf/updater/schedule/InverseScheduleSpace.java | 1 - .../arbiter/conf/updater/schedule/PolyScheduleSpace.java | 1 - .../conf/updater/schedule/SigmoidScheduleSpace.java | 1 - .../arbiter/conf/updater/schedule/StepScheduleSpace.java | 1 - .../arbiter/dropout/GaussianDropoutSpace.java | 1 - .../arbiter/layers/AbstractLSTMLayerSpace.java | 1 - .../org/deeplearning4j/arbiter/layers/BaseLayerSpace.java | 1 - .../arbiter/layers/BatchNormalizationSpace.java | 4 ++-- .../deeplearning4j/arbiter/layers/DropoutLayerSpace.java | 2 -- .../arbiter/layers/FeedForwardLayerSpace.java | 6 +++--- .../arbiter/layers/GravesLSTMLayerSpace.java | 6 +----- .../org/deeplearning4j/arbiter/layers/LSTMLayerSpace.java | 7 +------ .../org/deeplearning4j/arbiter/layers/LayerSpace.java | 2 +- .../arbiter/layers/SeparableConvolution2DLayerSpace.java | 2 +- .../listener/DL4JArbiterStatusReportingListener.java | 1 - .../arbiter/saver/local/FileModelSaver.java | 2 +- .../arbiter/scoring/impl/BaseNetScoreFunction.java | 1 - .../computationgraph/TestGraphLocalExecutionGenetic.java | 1 - .../java/org/deeplearning4j/arbiter/json/TestJson.java | 5 ----- .../arbiter/multilayernetwork/TestDL4JLocalExecution.java | 1 - .../arbiter/multilayernetwork/TestMultiLayerSpace.java | 3 +-- .../arbiter/util/TestDataFactoryProviderMnist.java | 3 --- .../arbiter/server/ArbiterCLIRunnerTest.java | 1 - 33 files changed, 20 insertions(+), 69 deletions(-) diff --git a/arbiter/arbiter-core/src/main/java/org/deeplearning4j/arbiter/optimize/api/CandidateGenerator.java b/arbiter/arbiter-core/src/main/java/org/deeplearning4j/arbiter/optimize/api/CandidateGenerator.java index b32cc58e7..6a88b4e10 100644 --- a/arbiter/arbiter-core/src/main/java/org/deeplearning4j/arbiter/optimize/api/CandidateGenerator.java +++ b/arbiter/arbiter-core/src/main/java/org/deeplearning4j/arbiter/optimize/api/CandidateGenerator.java @@ -16,10 +16,7 @@ package org.deeplearning4j.arbiter.optimize.api; -import org.deeplearning4j.arbiter.optimize.generator.GridSearchCandidateGenerator; -import org.deeplearning4j.arbiter.optimize.generator.RandomSearchGenerator; import org.nd4j.shade.jackson.annotation.JsonInclude; -import org.nd4j.shade.jackson.annotation.JsonSubTypes; import org.nd4j.shade.jackson.annotation.JsonTypeInfo; /** diff --git a/arbiter/arbiter-core/src/main/java/org/deeplearning4j/arbiter/optimize/config/OptimizationConfiguration.java b/arbiter/arbiter-core/src/main/java/org/deeplearning4j/arbiter/optimize/config/OptimizationConfiguration.java index d6e6f1025..4f7a9257b 100644 --- a/arbiter/arbiter-core/src/main/java/org/deeplearning4j/arbiter/optimize/config/OptimizationConfiguration.java +++ b/arbiter/arbiter-core/src/main/java/org/deeplearning4j/arbiter/optimize/config/OptimizationConfiguration.java @@ -29,7 +29,6 @@ import org.nd4j.shade.jackson.core.JsonProcessingException; import org.nd4j.shade.jackson.databind.annotation.JsonSerialize; import java.io.IOException; -import java.lang.reflect.Constructor; import java.util.Arrays; import java.util.List; import java.util.Properties; diff --git a/arbiter/arbiter-core/src/main/java/org/deeplearning4j/arbiter/optimize/distribution/DegenerateIntegerDistribution.java b/arbiter/arbiter-core/src/main/java/org/deeplearning4j/arbiter/optimize/distribution/DegenerateIntegerDistribution.java index c613d08b6..a1e3f359b 100644 --- a/arbiter/arbiter-core/src/main/java/org/deeplearning4j/arbiter/optimize/distribution/DegenerateIntegerDistribution.java +++ b/arbiter/arbiter-core/src/main/java/org/deeplearning4j/arbiter/optimize/distribution/DegenerateIntegerDistribution.java @@ -20,6 +20,8 @@ import org.apache.commons.math3.distribution.IntegerDistribution; import org.apache.commons.math3.exception.NumberIsTooLargeException; import org.apache.commons.math3.exception.OutOfRangeException; +import java.util.Arrays; + /** * Degenerate distribution: i.e., integer "distribution" that is just a fixed value */ @@ -89,8 +91,7 @@ public class DegenerateIntegerDistribution implements IntegerDistribution { @Override public int[] sample(int sampleSize) { int[] out = new int[sampleSize]; - for (int i = 0; i < out.length; i++) - out[i] = value; + Arrays.fill(out, value); return out; } } diff --git a/arbiter/arbiter-core/src/main/java/org/deeplearning4j/arbiter/optimize/parameter/continuous/ContinuousParameterSpace.java b/arbiter/arbiter-core/src/main/java/org/deeplearning4j/arbiter/optimize/parameter/continuous/ContinuousParameterSpace.java index d29c9dad7..4a8dfab9c 100644 --- a/arbiter/arbiter-core/src/main/java/org/deeplearning4j/arbiter/optimize/parameter/continuous/ContinuousParameterSpace.java +++ b/arbiter/arbiter-core/src/main/java/org/deeplearning4j/arbiter/optimize/parameter/continuous/ContinuousParameterSpace.java @@ -22,7 +22,6 @@ import org.deeplearning4j.arbiter.optimize.api.ParameterSpace; import org.deeplearning4j.arbiter.optimize.distribution.DistributionUtils; import org.deeplearning4j.arbiter.optimize.serde.jackson.RealDistributionDeserializer; import org.deeplearning4j.arbiter.optimize.serde.jackson.RealDistributionSerializer; -import org.nd4j.shade.jackson.annotation.JsonIgnoreProperties; import org.nd4j.shade.jackson.annotation.JsonProperty; import org.nd4j.shade.jackson.databind.annotation.JsonDeserialize; import org.nd4j.shade.jackson.databind.annotation.JsonSerialize; diff --git a/arbiter/arbiter-core/src/main/java/org/deeplearning4j/arbiter/optimize/parameter/discrete/DiscreteParameterSpace.java b/arbiter/arbiter-core/src/main/java/org/deeplearning4j/arbiter/optimize/parameter/discrete/DiscreteParameterSpace.java index b959a0352..9c37ae07d 100644 --- a/arbiter/arbiter-core/src/main/java/org/deeplearning4j/arbiter/optimize/parameter/discrete/DiscreteParameterSpace.java +++ b/arbiter/arbiter-core/src/main/java/org/deeplearning4j/arbiter/optimize/parameter/discrete/DiscreteParameterSpace.java @@ -19,7 +19,6 @@ package org.deeplearning4j.arbiter.optimize.parameter.discrete; import lombok.EqualsAndHashCode; import org.deeplearning4j.arbiter.optimize.api.ParameterSpace; import org.deeplearning4j.arbiter.util.ObjectUtils; -import org.nd4j.shade.jackson.annotation.JsonIgnoreProperties; import org.nd4j.shade.jackson.annotation.JsonProperty; import org.nd4j.shade.jackson.databind.annotation.JsonSerialize; diff --git a/arbiter/arbiter-core/src/main/java/org/deeplearning4j/arbiter/optimize/runner/BaseOptimizationRunner.java b/arbiter/arbiter-core/src/main/java/org/deeplearning4j/arbiter/optimize/runner/BaseOptimizationRunner.java index 0e04a130b..3f6a887a3 100644 --- a/arbiter/arbiter-core/src/main/java/org/deeplearning4j/arbiter/optimize/runner/BaseOptimizationRunner.java +++ b/arbiter/arbiter-core/src/main/java/org/deeplearning4j/arbiter/optimize/runner/BaseOptimizationRunner.java @@ -319,9 +319,7 @@ public abstract class BaseOptimizationRunner implements IOptimizationRunner { @Override public void removeListeners(StatusListener... listeners) { for (StatusListener l : listeners) { - if (statusListeners.contains(l)) { - statusListeners.remove(l); - } + statusListeners.remove(l); } } @@ -332,8 +330,7 @@ public abstract class BaseOptimizationRunner implements IOptimizationRunner { @Override public List getCandidateStatus() { - List list = new ArrayList<>(); - list.addAll(currentStatus.values()); + List list = new ArrayList<>(currentStatus.values()); return list; } diff --git a/arbiter/arbiter-core/src/test/java/org/deeplearning4j/arbiter/optimize/genetic/mutation/RandomMutationOperatorTests.java b/arbiter/arbiter-core/src/test/java/org/deeplearning4j/arbiter/optimize/genetic/mutation/RandomMutationOperatorTests.java index 5e4c60983..45ccaaa84 100644 --- a/arbiter/arbiter-core/src/test/java/org/deeplearning4j/arbiter/optimize/genetic/mutation/RandomMutationOperatorTests.java +++ b/arbiter/arbiter-core/src/test/java/org/deeplearning4j/arbiter/optimize/genetic/mutation/RandomMutationOperatorTests.java @@ -23,7 +23,6 @@ import org.junit.Assert; import org.junit.Test; import java.lang.reflect.Field; -import java.util.Arrays; public class RandomMutationOperatorTests extends BaseDL4JTest { @Test 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 36c8f791f..e3629bfb5 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 @@ -187,19 +187,19 @@ public abstract class BaseNetworkSpace extends AbstractParameterSpace { if (allParamConstraints != null){ List c = allParamConstraints.getValue(values); if(c != null){ - builder.constrainAllParameters(c.toArray(new LayerConstraint[c.size()])); + builder.constrainAllParameters(c.toArray(new LayerConstraint[0])); } } if (weightConstraints != null){ List c = weightConstraints.getValue(values); if(c != null){ - builder.constrainWeights(c.toArray(new LayerConstraint[c.size()])); + builder.constrainWeights(c.toArray(new LayerConstraint[0])); } } if (biasConstraints != null){ List c = biasConstraints.getValue(values); if(c != null){ - builder.constrainBias(c.toArray(new LayerConstraint[c.size()])); + builder.constrainBias(c.toArray(new LayerConstraint[0])); } } @@ -226,7 +226,7 @@ public abstract class BaseNetworkSpace extends AbstractParameterSpace { out.add(next); } else { Map m = next.getNestedSpaces(); - ParameterSpace[] arr = m.values().toArray(new ParameterSpace[m.size()]); + ParameterSpace[] arr = m.values().toArray(new ParameterSpace[0]); for (int i = arr.length - 1; i >= 0; i--) { stack.add(arr[i]); } diff --git a/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/conf/updater/AdaGradSpace.java b/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/conf/updater/AdaGradSpace.java index cc9df6ec9..3f33d1f03 100644 --- a/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/conf/updater/AdaGradSpace.java +++ b/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/conf/updater/AdaGradSpace.java @@ -18,18 +18,12 @@ package org.deeplearning4j.arbiter.conf.updater; import lombok.Data; import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.Setter; import org.deeplearning4j.arbiter.optimize.api.ParameterSpace; import org.nd4j.linalg.learning.config.AdaGrad; import org.nd4j.linalg.learning.config.IUpdater; import org.nd4j.linalg.schedule.ISchedule; import org.nd4j.shade.jackson.annotation.JsonProperty; -import java.util.Collections; -import java.util.List; -import java.util.Map; - @Data @EqualsAndHashCode(callSuper = false) public class AdaGradSpace extends BaseUpdaterSpace { diff --git a/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/conf/updater/BaseUpdaterSpace.java b/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/conf/updater/BaseUpdaterSpace.java index ec1eca996..90ea95c24 100644 --- a/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/conf/updater/BaseUpdaterSpace.java +++ b/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/conf/updater/BaseUpdaterSpace.java @@ -17,8 +17,6 @@ package org.deeplearning4j.arbiter.conf.updater; import lombok.Data; -import lombok.Getter; -import lombok.Setter; import org.deeplearning4j.arbiter.optimize.api.AbstractParameterSpace; import org.deeplearning4j.arbiter.optimize.api.ParameterSpace; import org.nd4j.linalg.learning.config.IUpdater; diff --git a/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/conf/updater/schedule/InverseScheduleSpace.java b/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/conf/updater/schedule/InverseScheduleSpace.java index e1296abfd..40808318b 100644 --- a/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/conf/updater/schedule/InverseScheduleSpace.java +++ b/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/conf/updater/schedule/InverseScheduleSpace.java @@ -21,7 +21,6 @@ import lombok.NoArgsConstructor; import lombok.NonNull; import org.deeplearning4j.arbiter.optimize.api.ParameterSpace; import org.deeplearning4j.arbiter.optimize.parameter.FixedValue; -import org.nd4j.linalg.schedule.ExponentialSchedule; import org.nd4j.linalg.schedule.ISchedule; import org.nd4j.linalg.schedule.InverseSchedule; import org.nd4j.linalg.schedule.ScheduleType; diff --git a/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/conf/updater/schedule/PolyScheduleSpace.java b/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/conf/updater/schedule/PolyScheduleSpace.java index 5ec0bcf7d..f902bdb5d 100644 --- a/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/conf/updater/schedule/PolyScheduleSpace.java +++ b/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/conf/updater/schedule/PolyScheduleSpace.java @@ -22,7 +22,6 @@ import lombok.NonNull; import org.deeplearning4j.arbiter.optimize.api.ParameterSpace; import org.deeplearning4j.arbiter.optimize.parameter.FixedValue; import org.nd4j.linalg.schedule.ISchedule; -import org.nd4j.linalg.schedule.InverseSchedule; import org.nd4j.linalg.schedule.PolySchedule; import org.nd4j.linalg.schedule.ScheduleType; import org.nd4j.shade.jackson.annotation.JsonProperty; diff --git a/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/conf/updater/schedule/SigmoidScheduleSpace.java b/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/conf/updater/schedule/SigmoidScheduleSpace.java index e7ebcde2d..336f5f32b 100644 --- a/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/conf/updater/schedule/SigmoidScheduleSpace.java +++ b/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/conf/updater/schedule/SigmoidScheduleSpace.java @@ -22,7 +22,6 @@ import lombok.NonNull; import org.deeplearning4j.arbiter.optimize.api.ParameterSpace; import org.deeplearning4j.arbiter.optimize.parameter.FixedValue; import org.nd4j.linalg.schedule.ISchedule; -import org.nd4j.linalg.schedule.PolySchedule; import org.nd4j.linalg.schedule.ScheduleType; import org.nd4j.linalg.schedule.SigmoidSchedule; import org.nd4j.shade.jackson.annotation.JsonProperty; diff --git a/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/conf/updater/schedule/StepScheduleSpace.java b/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/conf/updater/schedule/StepScheduleSpace.java index 2e0b6a598..104810d9b 100644 --- a/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/conf/updater/schedule/StepScheduleSpace.java +++ b/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/conf/updater/schedule/StepScheduleSpace.java @@ -22,7 +22,6 @@ import lombok.NonNull; import org.deeplearning4j.arbiter.optimize.api.ParameterSpace; import org.deeplearning4j.arbiter.optimize.parameter.FixedValue; import org.nd4j.linalg.schedule.ISchedule; -import org.nd4j.linalg.schedule.InverseSchedule; import org.nd4j.linalg.schedule.ScheduleType; import org.nd4j.linalg.schedule.StepSchedule; import org.nd4j.shade.jackson.annotation.JsonProperty; diff --git a/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/dropout/GaussianDropoutSpace.java b/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/dropout/GaussianDropoutSpace.java index 0cb345f40..d694a383f 100644 --- a/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/dropout/GaussianDropoutSpace.java +++ b/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/dropout/GaussianDropoutSpace.java @@ -19,7 +19,6 @@ package org.deeplearning4j.arbiter.dropout; import lombok.AllArgsConstructor; import org.deeplearning4j.arbiter.optimize.api.ParameterSpace; import org.deeplearning4j.arbiter.optimize.parameter.FixedValue; -import org.deeplearning4j.nn.conf.dropout.Dropout; import org.deeplearning4j.nn.conf.dropout.GaussianDropout; import org.deeplearning4j.nn.conf.dropout.IDropout; diff --git a/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/layers/AbstractLSTMLayerSpace.java b/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/layers/AbstractLSTMLayerSpace.java index 7cad81a82..d5b448f1e 100644 --- a/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/layers/AbstractLSTMLayerSpace.java +++ b/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/layers/AbstractLSTMLayerSpace.java @@ -25,7 +25,6 @@ import org.deeplearning4j.arbiter.optimize.api.ParameterSpace; import org.deeplearning4j.arbiter.optimize.parameter.FixedValue; import org.deeplearning4j.arbiter.util.LeafUtils; import org.deeplearning4j.nn.conf.layers.AbstractLSTM; -import org.deeplearning4j.nn.conf.layers.GravesLSTM; import org.nd4j.linalg.activations.Activation; import org.nd4j.linalg.activations.IActivation; diff --git a/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/layers/BaseLayerSpace.java b/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/layers/BaseLayerSpace.java index 0a5e33d27..5f218faac 100644 --- a/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/layers/BaseLayerSpace.java +++ b/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/layers/BaseLayerSpace.java @@ -26,7 +26,6 @@ import org.deeplearning4j.arbiter.optimize.api.ParameterSpace; import org.deeplearning4j.arbiter.optimize.parameter.FixedValue; import org.deeplearning4j.arbiter.optimize.parameter.discrete.DiscreteParameterSpace; import org.deeplearning4j.nn.conf.GradientNormalization; -import org.deeplearning4j.nn.conf.Updater; import org.deeplearning4j.nn.conf.distribution.Distribution; import org.deeplearning4j.nn.conf.layers.BaseLayer; import org.deeplearning4j.nn.conf.weightnoise.IWeightNoise; diff --git a/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/layers/BatchNormalizationSpace.java b/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/layers/BatchNormalizationSpace.java index 9b55555ed..09c1c071f 100644 --- a/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/layers/BatchNormalizationSpace.java +++ b/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/layers/BatchNormalizationSpace.java @@ -86,13 +86,13 @@ public class BatchNormalizationSpace extends FeedForwardLayerSpace c = constrainBeta.getValue(values); if(c != null){ - builder.constrainBeta(c.toArray(new LayerConstraint[c.size()])); + builder.constrainBeta(c.toArray(new LayerConstraint[0])); } } if (constrainGamma != null){ List c = constrainGamma.getValue(values); if(c != null){ - builder.constrainGamma(c.toArray(new LayerConstraint[c.size()])); + builder.constrainGamma(c.toArray(new LayerConstraint[0])); } } } diff --git a/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/layers/DropoutLayerSpace.java b/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/layers/DropoutLayerSpace.java index 1e6ca7157..1db5ec587 100644 --- a/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/layers/DropoutLayerSpace.java +++ b/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/layers/DropoutLayerSpace.java @@ -18,13 +18,11 @@ package org.deeplearning4j.arbiter.layers; import lombok.*; import org.deeplearning4j.arbiter.dropout.DropoutSpace; -import org.deeplearning4j.arbiter.optimize.api.AbstractParameterSpace; import org.deeplearning4j.arbiter.optimize.api.ParameterSpace; import org.deeplearning4j.arbiter.optimize.parameter.FixedValue; import org.deeplearning4j.nn.conf.dropout.IDropout; import org.deeplearning4j.nn.conf.layers.DropoutLayer; -import java.util.Collections; import java.util.List; @Data diff --git a/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/layers/FeedForwardLayerSpace.java b/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/layers/FeedForwardLayerSpace.java index 3ba0f3a06..3715071a6 100644 --- a/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/layers/FeedForwardLayerSpace.java +++ b/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/layers/FeedForwardLayerSpace.java @@ -56,19 +56,19 @@ public abstract class FeedForwardLayerSpace extends if (constrainWeights != null){ List c = constrainWeights.getValue(values); if(c != null){ - builder.constrainWeights(c.toArray(new LayerConstraint[c.size()])); + builder.constrainWeights(c.toArray(new LayerConstraint[0])); } } if (constrainBias != null){ List c = constrainBias.getValue(values); if(c != null){ - builder.constrainBias(c.toArray(new LayerConstraint[c.size()])); + builder.constrainBias(c.toArray(new LayerConstraint[0])); } } if (constrainAll != null){ List c = constrainAll.getValue(values); if(c != null){ - builder.constrainAllParameters(c.toArray(new LayerConstraint[c.size()])); + builder.constrainAllParameters(c.toArray(new LayerConstraint[0])); } } diff --git a/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/layers/GravesLSTMLayerSpace.java b/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/layers/GravesLSTMLayerSpace.java index 9707836fa..dd4a6d720 100644 --- a/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/layers/GravesLSTMLayerSpace.java +++ b/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/layers/GravesLSTMLayerSpace.java @@ -20,8 +20,6 @@ import lombok.AccessLevel; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; -import org.deeplearning4j.arbiter.optimize.api.ParameterSpace; -import org.deeplearning4j.arbiter.optimize.parameter.FixedValue; import org.deeplearning4j.arbiter.util.LeafUtils; import org.deeplearning4j.nn.conf.layers.GravesLSTM; @@ -60,9 +58,7 @@ public class GravesLSTMLayerSpace extends AbstractLSTMLayerSpace { @Override public String toString(String delim) { - StringBuilder sb = new StringBuilder("GravesLSTMLayerSpace("); - sb.append(super.toString(delim)).append(")"); - return sb.toString(); + return "GravesLSTMLayerSpace(" + super.toString(delim) + ")"; } public static class Builder extends AbstractLSTMLayerSpace.Builder { diff --git a/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/layers/LSTMLayerSpace.java b/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/layers/LSTMLayerSpace.java index 10e297134..0037e7645 100644 --- a/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/layers/LSTMLayerSpace.java +++ b/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/layers/LSTMLayerSpace.java @@ -20,10 +20,7 @@ import lombok.AccessLevel; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; -import org.deeplearning4j.arbiter.optimize.api.ParameterSpace; -import org.deeplearning4j.arbiter.optimize.parameter.FixedValue; import org.deeplearning4j.arbiter.util.LeafUtils; -import org.deeplearning4j.nn.conf.layers.GravesLSTM; import org.deeplearning4j.nn.conf.layers.LSTM; /** @@ -61,9 +58,7 @@ public class LSTMLayerSpace extends AbstractLSTMLayerSpace { @Override public String toString(String delim) { - StringBuilder sb = new StringBuilder("LSTMLayerSpace("); - sb.append(super.toString(delim)).append(")"); - return sb.toString(); + return "LSTMLayerSpace(" + super.toString(delim) + ")"; } public static class Builder extends AbstractLSTMLayerSpace.Builder { diff --git a/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/layers/LayerSpace.java b/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/layers/LayerSpace.java index 144e27f16..c0de63756 100644 --- a/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/layers/LayerSpace.java +++ b/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/layers/LayerSpace.java @@ -64,7 +64,7 @@ public abstract class LayerSpace extends AbstractParameterSpace out.add(next); } else { Map m = next.getNestedSpaces(); - ParameterSpace[] arr = m.values().toArray(new ParameterSpace[m.size()]); + ParameterSpace[] arr = m.values().toArray(new ParameterSpace[0]); for (int i = arr.length - 1; i >= 0; i--) { stack.add(arr[i]); } diff --git a/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/layers/SeparableConvolution2DLayerSpace.java b/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/layers/SeparableConvolution2DLayerSpace.java index 64a0d26a6..fd0f45dd3 100644 --- a/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/layers/SeparableConvolution2DLayerSpace.java +++ b/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/layers/SeparableConvolution2DLayerSpace.java @@ -66,7 +66,7 @@ public class SeparableConvolution2DLayerSpace extends BaseConvolutionLayerSpace< if (pointWiseConstraints != null){ List c = pointWiseConstraints.getValue(values); if(c != null){ - builder.constrainPointWise(c.toArray(new LayerConstraint[c.size()])); + builder.constrainPointWise(c.toArray(new LayerConstraint[0])); } } } diff --git a/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/listener/DL4JArbiterStatusReportingListener.java b/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/listener/DL4JArbiterStatusReportingListener.java index 0c89984c9..c6359822d 100644 --- a/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/listener/DL4JArbiterStatusReportingListener.java +++ b/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/listener/DL4JArbiterStatusReportingListener.java @@ -21,7 +21,6 @@ import org.deeplearning4j.arbiter.optimize.runner.CandidateInfo; import org.deeplearning4j.arbiter.optimize.runner.listener.StatusListener; import org.deeplearning4j.nn.api.Model; import org.deeplearning4j.optimize.api.BaseTrainingListener; -import org.deeplearning4j.optimize.api.IterationListener; import java.util.List; diff --git a/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/saver/local/FileModelSaver.java b/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/saver/local/FileModelSaver.java index b026e69f8..740418b4c 100644 --- a/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/saver/local/FileModelSaver.java +++ b/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/saver/local/FileModelSaver.java @@ -94,7 +94,7 @@ public class FileModelSaver implements ResultSaver { Object additionalResults = result.getModelSpecificResults(); - if (additionalResults != null && additionalResults instanceof Serializable) { + if (additionalResults instanceof Serializable) { try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(additionalResultsFile))) { oos.writeObject(additionalResults); } diff --git a/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/scoring/impl/BaseNetScoreFunction.java b/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/scoring/impl/BaseNetScoreFunction.java index 1d38ada7c..2de4d9ad1 100644 --- a/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/scoring/impl/BaseNetScoreFunction.java +++ b/arbiter/arbiter-deeplearning4j/src/main/java/org/deeplearning4j/arbiter/scoring/impl/BaseNetScoreFunction.java @@ -26,7 +26,6 @@ import org.nd4j.linalg.dataset.api.iterator.DataSetIterator; import org.nd4j.linalg.dataset.api.iterator.DataSetIteratorFactory; import org.nd4j.linalg.dataset.api.iterator.MultiDataSetIterator; -import java.io.IOException; import java.util.Arrays; import java.util.List; import java.util.Map; diff --git a/arbiter/arbiter-deeplearning4j/src/test/java/org/deeplearning4j/arbiter/computationgraph/TestGraphLocalExecutionGenetic.java b/arbiter/arbiter-deeplearning4j/src/test/java/org/deeplearning4j/arbiter/computationgraph/TestGraphLocalExecutionGenetic.java index 58a00bf5e..06dd2eefd 100644 --- a/arbiter/arbiter-deeplearning4j/src/test/java/org/deeplearning4j/arbiter/computationgraph/TestGraphLocalExecutionGenetic.java +++ b/arbiter/arbiter-deeplearning4j/src/test/java/org/deeplearning4j/arbiter/computationgraph/TestGraphLocalExecutionGenetic.java @@ -69,7 +69,6 @@ import java.util.Map; import java.util.Properties; import java.util.concurrent.TimeUnit; -import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @Slf4j diff --git a/arbiter/arbiter-deeplearning4j/src/test/java/org/deeplearning4j/arbiter/json/TestJson.java b/arbiter/arbiter-deeplearning4j/src/test/java/org/deeplearning4j/arbiter/json/TestJson.java index 12ccc71a5..c64c21814 100644 --- a/arbiter/arbiter-deeplearning4j/src/test/java/org/deeplearning4j/arbiter/json/TestJson.java +++ b/arbiter/arbiter-deeplearning4j/src/test/java/org/deeplearning4j/arbiter/json/TestJson.java @@ -24,7 +24,6 @@ import org.deeplearning4j.arbiter.conf.updater.AdamSpace; import org.deeplearning4j.arbiter.conf.updater.SgdSpace; import org.deeplearning4j.arbiter.layers.DenseLayerSpace; import org.deeplearning4j.arbiter.layers.OutputLayerSpace; -import org.deeplearning4j.arbiter.multilayernetwork.MnistDataSetIteratorFactory; import org.deeplearning4j.arbiter.optimize.api.CandidateGenerator; import org.deeplearning4j.arbiter.optimize.api.ParameterSpace; import org.deeplearning4j.arbiter.optimize.api.data.DataProvider; @@ -47,12 +46,8 @@ import org.deeplearning4j.datasets.iterator.impl.IrisDataSetIterator; import org.deeplearning4j.datasets.iterator.impl.MnistDataSetIterator; import org.deeplearning4j.earlystopping.EarlyStoppingConfiguration; import org.deeplearning4j.earlystopping.saver.InMemoryModelSaver; -import org.deeplearning4j.earlystopping.scorecalc.ClassificationScoreCalculator; import org.deeplearning4j.earlystopping.scorecalc.DataSetLossCalculatorCG; -import org.deeplearning4j.earlystopping.scorecalc.base.BaseIEvaluationScoreCalculator; import org.deeplearning4j.earlystopping.termination.MaxEpochsTerminationCondition; -import org.deeplearning4j.eval.Evaluation; -import org.deeplearning4j.eval.IEvaluation; import org.deeplearning4j.nn.api.OptimizationAlgorithm; import org.deeplearning4j.nn.conf.inputs.InputType; import org.deeplearning4j.nn.graph.ComputationGraph; diff --git a/arbiter/arbiter-deeplearning4j/src/test/java/org/deeplearning4j/arbiter/multilayernetwork/TestDL4JLocalExecution.java b/arbiter/arbiter-deeplearning4j/src/test/java/org/deeplearning4j/arbiter/multilayernetwork/TestDL4JLocalExecution.java index 554ef346e..6f1cc63cd 100644 --- a/arbiter/arbiter-deeplearning4j/src/test/java/org/deeplearning4j/arbiter/multilayernetwork/TestDL4JLocalExecution.java +++ b/arbiter/arbiter-deeplearning4j/src/test/java/org/deeplearning4j/arbiter/multilayernetwork/TestDL4JLocalExecution.java @@ -72,7 +72,6 @@ import java.util.Map; import java.util.Properties; import java.util.concurrent.TimeUnit; -import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @Slf4j 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 be8a3133f..3b1d2d00e 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 @@ -384,8 +384,7 @@ public class TestMultiLayerSpace extends BaseDL4JTest { double[] ones = new double[numParams]; - for (int i = 0; i < ones.length; i++) - ones[i] = 1.0; + Arrays.fill(ones, 1.0); configuration = mls.getValue(ones); diff --git a/arbiter/arbiter-deeplearning4j/src/test/java/org/deeplearning4j/arbiter/util/TestDataFactoryProviderMnist.java b/arbiter/arbiter-deeplearning4j/src/test/java/org/deeplearning4j/arbiter/util/TestDataFactoryProviderMnist.java index 4416dd8cf..35efdaf3c 100644 --- a/arbiter/arbiter-deeplearning4j/src/test/java/org/deeplearning4j/arbiter/util/TestDataFactoryProviderMnist.java +++ b/arbiter/arbiter-deeplearning4j/src/test/java/org/deeplearning4j/arbiter/util/TestDataFactoryProviderMnist.java @@ -17,14 +17,11 @@ package org.deeplearning4j.arbiter.util; import lombok.AllArgsConstructor; -import org.deeplearning4j.arbiter.optimize.api.data.DataProvider; import org.deeplearning4j.datasets.iterator.EarlyTerminationDataSetIterator; import org.deeplearning4j.datasets.iterator.impl.MnistDataSetIterator; import org.nd4j.linalg.dataset.api.iterator.DataSetIterator; import org.nd4j.linalg.dataset.api.iterator.DataSetIteratorFactory; -import java.util.Map; - @AllArgsConstructor public class TestDataFactoryProviderMnist implements DataSetIteratorFactory { diff --git a/arbiter/arbiter-server/src/test/java/org/deeplearning4j/arbiter/server/ArbiterCLIRunnerTest.java b/arbiter/arbiter-server/src/test/java/org/deeplearning4j/arbiter/server/ArbiterCLIRunnerTest.java index 3aaff2ed8..b5dabe1d1 100644 --- a/arbiter/arbiter-server/src/test/java/org/deeplearning4j/arbiter/server/ArbiterCLIRunnerTest.java +++ b/arbiter/arbiter-server/src/test/java/org/deeplearning4j/arbiter/server/ArbiterCLIRunnerTest.java @@ -38,7 +38,6 @@ import org.deeplearning4j.arbiter.scoring.impl.TestSetLossScoreFunction; import org.deeplearning4j.nn.api.OptimizationAlgorithm; import org.junit.Test; import org.nd4j.linalg.activations.Activation; -import org.nd4j.linalg.learning.config.Sgd; import org.nd4j.linalg.lossfunctions.LossFunctions; import java.io.File;