From ccb216a3edaa1e2b9e6401433b8e66ac681ff22d Mon Sep 17 00:00:00 2001 From: Alexander Stoyakin Date: Thu, 23 Apr 2020 01:36:49 +0300 Subject: [PATCH] Fixing issues from Sonar report (#391) * Fixing issues from Sonar report * Proper logger of exceptions * Coding style fixes * Use dup parameter * Cleanup, minor issues * Cuda compilation fixed and some minor fixes --- .../records/reader/impl/LineRecordReader.java | 6 ++-- .../api/split/NumberedFileInputSplit.java | 4 ++- .../java/org/datavec/api/writable/Text.java | 1 - .../arrow/recordreader/ArrowRecordReader.java | 6 ++-- .../org/datavec/arrow/ArrowConverterTest.java | 5 +-- .../src/main/java/org/datavec/audio/Wave.java | 4 +-- .../org/datavec/audio/WaveFileManager.java | 6 ++-- .../java/org/datavec/audio/WaveHeader.java | 5 ++- .../audio/fingerprint/FingerprintManager.java | 8 +++-- .../org/datavec/image/loader/CifarLoader.java | 10 +++--- .../org/datavec/image/loader/LFWLoader.java | 4 +-- .../recordreader/BaseImageRecordReader.java | 2 +- .../image/loader/TestNativeImageLoader.java | 8 +++-- .../tokenization/tokenizer/UimaTokenizer.java | 2 +- .../SequenceRecordReaderFunction.java | 4 ++- .../client/DataVecTransformClient.java | 13 +------ .../spark/transform/CSVSparkTransform.java | 5 +-- .../transform/ImageSparkTransformServer.java | 12 +++---- .../java/org/datavec/spark/BaseSparkTest.java | 4 ++- .../impl/RemoteUIStatsStorageRouter.java | 15 ++++---- .../parallelism/AsyncIterator.java | 5 +-- .../listener/SystemInfoPrintListener.java | 12 +++---- .../perf/listener/SystemPolling.java | 4 ++- .../org/deeplearning4j/util/ModelGuesser.java | 1 - .../RecordReaderDataSetiteratorTest.java | 2 +- .../EarlyTerminationDataSetIteratorTest.java | 4 +-- .../iterator/MultipleEpochsIteratorTest.java | 2 +- .../datasets/iterator/SamplingTest.java | 2 +- .../exceptions/TestInvalidConfigurations.java | 28 ++++++++------- .../exceptions/TestInvalidInput.java | 24 +++++++------ .../LossFunctionGradientCheck.java | 6 ++-- .../ComputationGraphConfigurationTest.java | 16 +++++---- .../MultiLayerNeuralNetConfigurationTest.java | 14 ++++---- .../nn/conf/constraints/TestConstraints.java | 36 +++++++++---------- .../nn/conf/layers/LayerBuilderTest.java | 2 +- .../nn/graph/ComputationGraphTestRNN.java | 4 ++- .../nn/graph/TestComputationGraphNetwork.java | 2 +- .../nn/graph/TestVariableLengthTSCG.java | 4 +-- .../convolution/TestConvolutionModes.java | 10 +++--- .../layers/recurrent/MaskZeroLayerTest.java | 12 +++---- .../nn/multilayer/MultiLayerTestRNN.java | 2 +- .../nn/multilayer/TestVariableLengthTS.java | 4 +-- .../nn/updater/TestUpdaters.java | 2 +- .../regressiontest/RegressionTest050.java | 4 +-- .../regressiontest/RegressionTest060.java | 4 +-- .../regressiontest/RegressionTest071.java | 2 +- .../regressiontest/RegressionTest080.java | 4 +-- .../datasets/fetchers/EmnistDataFetcher.java | 4 ++- .../deeplearning4j/plot/BarnesHutTsne.java | 16 ++------- .../nn/modelimport/keras/Hdf5Archive.java | 2 +- .../configurations/KerasModelImportTest.java | 4 +-- .../server/NearestNeighborsServer.java | 2 -- .../recognition/impl/StopRecognition.java | 1 - .../compile/DictionaryCompilerBase.java | 4 ++- .../kuromoji/util/FileResourceResolver.java | 1 - .../text/corpora/sentiwordnet/SWN3.java | 4 ++- .../tokenization/tokenizer/UimaTokenizer.java | 4 ++- .../models/word2vec/Word2VecTests.java | 4 ++- .../listeners/SerializingListener.java | 4 ++- .../ParallelTransformerIterator.java | 2 +- .../AsyncLabelAwareIterator.java | 3 +- .../sentenceiterator/BasicLineIterator.java | 4 ++- .../sentenceiterator/StreamLineIterator.java | 6 ++-- .../models/fasttext/FastTextTest.java | 2 +- .../ParagraphVectorsTest.java | 2 +- .../WordVectorSerializerTest.java | 12 ++++--- .../wordstore/inmemory/AbstractCacheTest.java | 4 +-- .../nn/layers/AbstractLayer.java | 2 +- .../deeplearning4j/nn/layers/BaseLayer.java | 4 ++- .../remote/BinaryModelServerTest.java | 8 +++-- .../remote/JsonModelServerTest.java | 6 ++-- .../parallelism/ParallelInferenceTest.java | 6 ++-- .../text/functions/TokenizerFunction.java | 4 ++- .../networking/v2/UpdatesConsumer.java | 2 +- .../datavec/DataVecByteDataSetFunction.java | 4 ++- .../spark/datavec/DataVecDataSetFunction.java | 5 ++- .../repartition/BalancedPartitionerTest.java | 10 +++--- .../ui/stats/BaseStatsListener.java | 2 +- .../ConvolutionalIterationListener.java | 6 ++-- .../org/deeplearning4j/ui/ManualTests.java | 4 ++- .../ui/module/train/TrainModule.java | 2 +- .../ui/TestVertxUIMultiSession.java | 6 ++-- .../org/deeplearning4j/zoo/model/AlexNet.java | 1 - .../integration/IntegrationTestRunner.java | 2 +- .../functions/DifferentialFunction.java | 2 +- .../org/nd4j/autodiff/listeners/Loss.java | 2 +- .../listeners/impl/HistoryListener.java | 6 ---- .../internal/AbstractDependencyTracker.java | 22 ++++++------ .../nd4j/evaluation/custom/MergeLambda.java | 2 -- .../activations/impl/ActivationMish.java | 2 -- .../linalg/api/ops/custom/LinearSolve.java | 1 - .../org/nd4j/linalg/api/ops/custom/Lstsq.java | 1 - .../linalg/api/ops/impl/indexaccum/IAMax.java | 1 - .../linalg/api/ops/impl/indexaccum/IAMin.java | 1 - .../impl/layers/convolution/AvgPooling3D.java | 2 +- .../layers/convolution/MaxPoolWithArgmax.java | 2 +- .../impl/layers/convolution/MaxPooling2D.java | 2 +- .../impl/layers/convolution/MaxPooling3D.java | 2 +- .../config/BaseConvolutionConfig.java | 5 ++- .../ops/impl/layers/recurrent/LSTMLayer.java | 2 -- .../recurrent/config/LSTMLayerConfig.java | 2 -- .../recurrent/outputs/LSTMLayerOutputs.java | 7 ---- .../recurrent/weights/LSTMLayerWeights.java | 1 - .../ops/impl/loss/AbsoluteDifferenceLoss.java | 2 -- .../api/ops/impl/loss/CosineDistanceLoss.java | 2 -- .../linalg/api/ops/impl/loss/HingeLoss.java | 1 - .../linalg/api/ops/impl/loss/HuberLoss.java | 1 - .../loss/MeanPairwiseSquaredErrorLoss.java | 1 - .../ops/impl/loss/MeanSquaredErrorLoss.java | 1 - .../loss/bp/AbsoluteDifferenceLossBp.java | 1 - .../api/ops/impl/loss/bp/HingeLossBp.java | 1 - .../ops/impl/loss/bp/LogPoissonLossBp.java | 6 ++-- .../impl/loss/bp/MeanSquaredErrorLossBp.java | 1 - .../api/ops/impl/reduce/bool/IsInf.java | 1 - .../api/ops/impl/reduce/bp/VarianceBp.java | 5 ++- .../api/ops/impl/reduce/floating/Mean.java | 1 - .../ops/impl/reduce/longer/CountNonZero.java | 1 - .../linalg/api/ops/impl/shape/GatherNd.java | 2 -- .../linalg/api/ops/impl/shape/Linspace.java | 2 -- .../api/ops/impl/summarystats/Variance.java | 6 ++-- .../api/ops/impl/transforms/Histogram.java | 1 - .../ops/impl/transforms/bool/IsFinite.java | 1 - .../api/ops/impl/transforms/bool/IsNaN.java | 2 -- .../bool/MatchConditionTransform.java | 2 -- .../transforms/custom/InvertPermutation.java | 1 - .../ops/impl/transforms/custom/MaximumBp.java | 1 - .../transforms/gradient/CubeDerivative.java | 1 - .../gradient/HardSigmoidDerivative.java | 1 - .../gradient/HardTanhDerivative.java | 2 -- .../pairwise/arithmetic/MergeAddOp.java | 4 --- .../pairwise/arithmetic/bp/MergeAddBp.java | 1 - .../api/ops/impl/transforms/same/Cube.java | 5 --- .../api/ops/impl/transforms/same/Max.java | 2 -- .../api/ops/impl/transforms/strict/ACos.java | 2 -- .../api/ops/impl/transforms/strict/ACosh.java | 2 -- .../api/ops/impl/transforms/strict/ASin.java | 3 -- .../api/ops/impl/transforms/strict/ASinh.java | 2 -- .../api/ops/impl/transforms/strict/ATan.java | 2 -- .../api/ops/impl/transforms/strict/ATanh.java | 2 -- .../api/ops/impl/transforms/strict/Cos.java | 2 -- .../api/ops/impl/transforms/strict/Cosh.java | 2 -- .../api/ops/impl/transforms/strict/ELU.java | 1 - .../ops/impl/transforms/strict/HardTanh.java | 5 --- .../impl/transforms/strict/LogSigmoid.java | 3 -- .../ops/random/impl/BinomialDistribution.java | 1 + .../linalg/api/ops/random/impl/DropOut.java | 4 --- .../java/org/nd4j/linalg/dataset/DataSet.java | 2 +- .../dataset/MiniBatchFileDataSetIterator.java | 5 ++- .../AbstractDataSetNormalizer.java | 6 ++-- .../CompositeDataSetPreProcessor.java | 2 -- .../java/org/nd4j/linalg/factory/Nd4j.java | 6 ++-- .../org/nd4j/linalg/factory/Nd4jBackend.java | 2 +- .../lossfunctions/impl/LossSparseMCXENT.java | 6 ---- .../linalg/ops/transforms/Transforms.java | 9 +++-- .../org/nd4j/serde/binary/BinarySerde.java | 2 +- .../ProtectedCudaConstantHandler.java | 2 ++ .../nd4j/linalg/jcublas/CublasPointer.java | 4 ++- .../jcublas/buffer/CudaFloatDataBuffer.java | 4 ++- .../profiling/OperationProfilerTests.java | 2 +- .../io/AbstractFileResolvingResource.java | 6 ++++ .../java/org/nd4j/linalg/util/ArrayUtil.java | 14 ++++---- .../java/org/nd4j/linalg/util/MathUtils.java | 4 +-- .../nd4j/jdbc/driverfinder/DriverFinder.java | 7 ++-- .../org/nd4j/jdbc/hsql/HSqlLoaderTest.java | 4 ++- .../client/ParameterServerClient.java | 6 ++-- .../background/BackgroundDaemonStarter.java | 4 +-- .../RemoteParameterServerClientTests.java | 4 +-- .../intercom/DistributedAssignMessage.java | 1 - .../v2/chunks/impl/FileChunksTracker.java | 4 ++- .../v2/util/AbstractUpdatesHandler.java | 1 - .../ParameterServerSubscriber.java | 4 ++- .../clients/serde/impl/DoubleArraySerde.java | 7 ---- .../aeron/ipc/AeronNDArraySubscriber.java | 4 +-- .../ipc/response/AeronNDArrayResponder.java | 4 +-- .../NDArrayResponseFragmentHandler.java | 6 ++-- .../nd4j/aeron/ipc/LargeNdArrayIpcTest.java | 2 +- .../org/nd4j/aeron/ipc/NdArrayIpcTest.java | 6 ++-- .../conversion/graphrunner/GraphRunner.java | 8 ++--- 178 files changed, 376 insertions(+), 422 deletions(-) diff --git a/datavec/datavec-api/src/main/java/org/datavec/api/records/reader/impl/LineRecordReader.java b/datavec/datavec-api/src/main/java/org/datavec/api/records/reader/impl/LineRecordReader.java index 0fd5793b8..f951c89a3 100644 --- a/datavec/datavec-api/src/main/java/org/datavec/api/records/reader/impl/LineRecordReader.java +++ b/datavec/datavec-api/src/main/java/org/datavec/api/records/reader/impl/LineRecordReader.java @@ -18,6 +18,7 @@ package org.datavec.api.records.reader.impl; import lombok.Getter; import lombok.Setter; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.IOUtils; import org.apache.commons.io.LineIterator; import org.datavec.api.conf.Configuration; @@ -43,6 +44,7 @@ import java.util.*; * * @author Adam Gibson */ +@Slf4j public class LineRecordReader extends BaseRecordReader { @@ -89,7 +91,7 @@ public class LineRecordReader extends BaseRecordReader { iter = getIterator(splitIndex); onLocationOpen(locations[splitIndex]); } catch (IOException e) { - e.printStackTrace(); + log.error("",e); } if (iter.hasNext()) { @@ -120,7 +122,7 @@ public class LineRecordReader extends BaseRecordReader { iter = getIterator(splitIndex); onLocationOpen(locations[splitIndex]); } catch (IOException e) { - e.printStackTrace(); + log.error("",e); } return iter.hasNext(); diff --git a/datavec/datavec-api/src/main/java/org/datavec/api/split/NumberedFileInputSplit.java b/datavec/datavec-api/src/main/java/org/datavec/api/split/NumberedFileInputSplit.java index 2985462c8..5227a0cc3 100644 --- a/datavec/datavec-api/src/main/java/org/datavec/api/split/NumberedFileInputSplit.java +++ b/datavec/datavec-api/src/main/java/org/datavec/api/split/NumberedFileInputSplit.java @@ -16,6 +16,7 @@ package org.datavec.api.split; +import lombok.extern.slf4j.Slf4j; import org.datavec.api.util.files.UriFromPathIterator; import org.datavec.api.writable.WritableType; @@ -34,6 +35,7 @@ import java.util.regex.Pattern; * NumberedFileInputSplit utilizes String.format(), hence the requirement for "%d" to represent * the integer index. */ +@Slf4j public class NumberedFileInputSplit implements InputSplit { private final String baseString; private final int minIdx; @@ -93,7 +95,7 @@ public class NumberedFileInputSplit implements InputSplit { try { writeFile.createNewFile(); } catch (IOException e) { - e.printStackTrace(); + log.error("",e); } diff --git a/datavec/datavec-api/src/main/java/org/datavec/api/writable/Text.java b/datavec/datavec-api/src/main/java/org/datavec/api/writable/Text.java index d3c5b03d4..bdf401f1e 100644 --- a/datavec/datavec-api/src/main/java/org/datavec/api/writable/Text.java +++ b/datavec/datavec-api/src/main/java/org/datavec/api/writable/Text.java @@ -162,7 +162,6 @@ public class Text extends BinaryComparable implements WritableComparableasList(ndArrayWritable); } catch (IOException e) { - e.printStackTrace(); + log.error("",e); } } if (iter != null) { diff --git a/datavec/datavec-data/datavec-data-image/src/test/java/org/datavec/image/loader/TestNativeImageLoader.java b/datavec/datavec-data/datavec-data-image/src/test/java/org/datavec/image/loader/TestNativeImageLoader.java index b8fa0c43d..9d139cbf5 100644 --- a/datavec/datavec-data/datavec-data-image/src/test/java/org/datavec/image/loader/TestNativeImageLoader.java +++ b/datavec/datavec-data/datavec-data-image/src/test/java/org/datavec/image/loader/TestNativeImageLoader.java @@ -16,6 +16,7 @@ package org.datavec.image.loader; +import lombok.extern.slf4j.Slf4j; import lombok.val; import org.apache.commons.io.IOUtils; import org.bytedeco.javacpp.Loader; @@ -53,6 +54,7 @@ import static org.junit.Assert.fail; * * @author saudet */ +@Slf4j public class TestNativeImageLoader { static final long seed = 10; static final Random rng = new Random(seed); @@ -123,7 +125,7 @@ public class TestNativeImageLoader { try { array6 = loader5.asMatrix(new ClassPathResource(path2MitosisFile).getFile().getAbsolutePath()); } catch (IOException e) { - e.printStackTrace(); + log.error("",e); fail(); } assertEquals(5, array6.rank()); @@ -156,7 +158,7 @@ public class TestNativeImageLoader { try { array8 = loader7.asMatrix(new ClassPathResource(path2MitosisFile).getFile().getAbsolutePath()); } catch (IOException e) { - e.printStackTrace(); + log.error("",e); } assertEquals(5, array8.rank()); assertEquals(pages2, array8.size(0)); @@ -172,7 +174,7 @@ public class TestNativeImageLoader { try { array9 = loader8.asMatrix(new ClassPathResource(braintiff).getFile().getAbsolutePath()); } catch (IOException e) { - e.printStackTrace(); + log.error("",e); fail(); } assertEquals(5, array9.rank()); diff --git a/datavec/datavec-data/datavec-data-nlp/src/main/java/org/datavec/nlp/tokenization/tokenizer/UimaTokenizer.java b/datavec/datavec-data/datavec-data-nlp/src/main/java/org/datavec/nlp/tokenization/tokenizer/UimaTokenizer.java index 7ac2b2969..eb14fdabd 100644 --- a/datavec/datavec-data/datavec-data-nlp/src/main/java/org/datavec/nlp/tokenization/tokenizer/UimaTokenizer.java +++ b/datavec/datavec-data/datavec-data-nlp/src/main/java/org/datavec/nlp/tokenization/tokenizer/UimaTokenizer.java @@ -66,7 +66,7 @@ public class UimaTokenizer implements Tokenizer { } catch (Exception e) { - e.printStackTrace(); + log.error("",e); throw new RuntimeException(e); } diff --git a/datavec/datavec-local/src/main/java/org/datavec/local/transforms/functions/SequenceRecordReaderFunction.java b/datavec/datavec-local/src/main/java/org/datavec/local/transforms/functions/SequenceRecordReaderFunction.java index 70391f66f..94026f2cf 100644 --- a/datavec/datavec-local/src/main/java/org/datavec/local/transforms/functions/SequenceRecordReaderFunction.java +++ b/datavec/datavec-local/src/main/java/org/datavec/local/transforms/functions/SequenceRecordReaderFunction.java @@ -17,6 +17,7 @@ package org.datavec.local.transforms.functions; +import lombok.extern.slf4j.Slf4j; import org.datavec.api.records.reader.SequenceRecordReader; import org.datavec.api.writable.Writable; import org.nd4j.linalg.function.Function; @@ -32,6 +33,7 @@ import java.util.List; * sequence data into a {@code List>} * @author Alex Black */ +@Slf4j public class SequenceRecordReaderFunction implements Function, List>> { protected SequenceRecordReader sequenceRecordReader; @@ -46,7 +48,7 @@ public class SequenceRecordReaderFunction try (DataInputStream dis = (DataInputStream) value.getRight()) { return sequenceRecordReader.sequenceRecord(uri, dis); } catch (IOException e) { - e.printStackTrace(); + log.error("",e); } throw new IllegalStateException("Something went wrong"); diff --git a/datavec/datavec-spark-inference-parent/datavec-spark-inference-client/src/main/java/org/datavec/spark/transform/client/DataVecTransformClient.java b/datavec/datavec-spark-inference-parent/datavec-spark-inference-client/src/main/java/org/datavec/spark/transform/client/DataVecTransformClient.java index e84488f9d..a481f2cea 100644 --- a/datavec/datavec-spark-inference-parent/datavec-spark-inference-client/src/main/java/org/datavec/spark/transform/client/DataVecTransformClient.java +++ b/datavec/datavec-spark-inference-parent/datavec-spark-inference-client/src/main/java/org/datavec/spark/transform/client/DataVecTransformClient.java @@ -74,7 +74,6 @@ public class DataVecTransformClient implements DataVecTransformService { } catch (UnirestException e) { log.error("Error in setCSVTransformProcess()", e); - e.printStackTrace(); } } @@ -94,7 +93,6 @@ public class DataVecTransformClient implements DataVecTransformService { return TransformProcess.fromJson(s); } catch (UnirestException e) { log.error("Error in getCSVTransformProcess()",e); - e.printStackTrace(); } return null; @@ -119,7 +117,6 @@ public class DataVecTransformClient implements DataVecTransformService { return singleCsvRecord; } catch (UnirestException e) { log.error("Error in transformIncremental(SingleCSVRecord)",e); - e.printStackTrace(); } return null; } @@ -140,8 +137,7 @@ public class DataVecTransformClient implements DataVecTransformService { .getBody(); return batchCSVRecord1; } catch (UnirestException e) { - log.error("Error in transform(BatchCSVRecord)", e); - e.printStackTrace(); + log.error("",e); } return null; @@ -162,7 +158,6 @@ public class DataVecTransformClient implements DataVecTransformService { return batchCSVRecord1; } catch (UnirestException e) { log.error("Error in transform(BatchCSVRecord)", e); - e.printStackTrace(); } return null; @@ -181,7 +176,6 @@ public class DataVecTransformClient implements DataVecTransformService { return batchArray1; } catch (UnirestException e) { log.error("Error in transformArray(BatchCSVRecord)",e); - e.printStackTrace(); } return null; @@ -200,7 +194,6 @@ public class DataVecTransformClient implements DataVecTransformService { return array; } catch (UnirestException e) { log.error("Error in transformArrayIncremental(SingleCSVRecord)",e); - e.printStackTrace(); } return null; @@ -231,7 +224,6 @@ public class DataVecTransformClient implements DataVecTransformService { return array; } catch (UnirestException e) { log.error("Error in transformSequenceArrayIncremental",e); - e.printStackTrace(); } return null; @@ -252,7 +244,6 @@ public class DataVecTransformClient implements DataVecTransformService { return batchArray1; } catch (UnirestException e) { log.error("Error in transformSequenceArray",e); - e.printStackTrace(); } return null; @@ -274,7 +265,6 @@ public class DataVecTransformClient implements DataVecTransformService { return batchCSVRecord1; } catch (UnirestException e) { log.error("Error in transformSequence"); - e.printStackTrace(); } return null; @@ -295,7 +285,6 @@ public class DataVecTransformClient implements DataVecTransformService { return singleCsvRecord; } catch (UnirestException e) { log.error("Error in transformSequenceIncremental"); - e.printStackTrace(); } return null; } diff --git a/datavec/datavec-spark-inference-parent/datavec-spark-inference-model/src/main/java/org/datavec/spark/transform/CSVSparkTransform.java b/datavec/datavec-spark-inference-parent/datavec-spark-inference-model/src/main/java/org/datavec/spark/transform/CSVSparkTransform.java index f76e9885f..bc7ad126c 100644 --- a/datavec/datavec-spark-inference-parent/datavec-spark-inference-model/src/main/java/org/datavec/spark/transform/CSVSparkTransform.java +++ b/datavec/datavec-spark-inference-parent/datavec-spark-inference-model/src/main/java/org/datavec/spark/transform/CSVSparkTransform.java @@ -18,6 +18,7 @@ package org.datavec.spark.transform; import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.extern.slf4j.Slf4j; import lombok.val; import org.apache.arrow.memory.BufferAllocator; import org.apache.arrow.memory.RootAllocator; @@ -53,7 +54,7 @@ import static org.datavec.local.transforms.LocalTransformExecutor.executeToSeque * @author Adan Gibson */ @AllArgsConstructor - +@Slf4j public class CSVSparkTransform { @Getter private TransformProcess transformProcess; @@ -252,7 +253,7 @@ public class CSVSparkTransform { try { return new Base64NDArrayBody(Nd4jBase64.base64String(arr)); } catch (IOException e) { - e.printStackTrace(); + log.error("",e); } return null; diff --git a/datavec/datavec-spark-inference-parent/datavec-spark-inference-server/src/main/java/org/datavec/spark/transform/ImageSparkTransformServer.java b/datavec/datavec-spark-inference-parent/datavec-spark-inference-server/src/main/java/org/datavec/spark/transform/ImageSparkTransformServer.java index f8675f139..d64416d32 100644 --- a/datavec/datavec-spark-inference-parent/datavec-spark-inference-server/src/main/java/org/datavec/spark/transform/ImageSparkTransformServer.java +++ b/datavec/datavec-spark-inference-parent/datavec-spark-inference-server/src/main/java/org/datavec/spark/transform/ImageSparkTransformServer.java @@ -88,7 +88,7 @@ public class ImageSparkTransformServer extends SparkTransformServer { log.info("Transform process initialized"); return ok(objectMapper.writeValueAsString(transform.getImageTransformProcess())).as(contentType); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); return internalServerError(); } }); @@ -100,7 +100,7 @@ public class ImageSparkTransformServer extends SparkTransformServer { log.info("Transform process initialized"); return ok(objectMapper.writeValueAsString(transformProcess)).as(contentType); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); return internalServerError(); } }); @@ -112,7 +112,7 @@ public class ImageSparkTransformServer extends SparkTransformServer { return badRequest(); return ok(objectMapper.writeValueAsString(transformIncrementalArray(record))).as(contentType); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); return internalServerError(); } }); @@ -130,7 +130,7 @@ public class ImageSparkTransformServer extends SparkTransformServer { return ok(objectMapper.writeValueAsString(transformIncrementalArray(record))).as(contentType); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); return internalServerError(); } }); @@ -142,7 +142,7 @@ public class ImageSparkTransformServer extends SparkTransformServer { return badRequest(); return ok(objectMapper.writeValueAsString(transformArray(batch))).as(contentType); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); return internalServerError(); } }); @@ -169,7 +169,7 @@ public class ImageSparkTransformServer extends SparkTransformServer { return ok(objectMapper.writeValueAsString(transformArray(batch))).as(contentType); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); return internalServerError(); } }); diff --git a/datavec/datavec-spark/src/test/java/org/datavec/spark/BaseSparkTest.java b/datavec/datavec-spark/src/test/java/org/datavec/spark/BaseSparkTest.java index 92a11f779..c474f8962 100644 --- a/datavec/datavec-spark/src/test/java/org/datavec/spark/BaseSparkTest.java +++ b/datavec/datavec-spark/src/test/java/org/datavec/spark/BaseSparkTest.java @@ -16,6 +16,7 @@ package org.datavec.spark; +import lombok.extern.slf4j.Slf4j; import org.apache.spark.SparkConf; import org.apache.spark.api.java.JavaSparkContext; import org.junit.After; @@ -23,6 +24,7 @@ import org.junit.Before; import java.io.Serializable; +@Slf4j public abstract class BaseSparkTest implements Serializable { protected static JavaSparkContext sc; @@ -40,7 +42,7 @@ public abstract class BaseSparkTest implements Serializable { try { Thread.sleep(100L); } catch (InterruptedException e) { - e.printStackTrace(); + log.error("",e); } } else { break; diff --git a/deeplearning4j/deeplearning4j-core/src/main/java/org/deeplearning4j/api/storage/impl/RemoteUIStatsStorageRouter.java b/deeplearning4j/deeplearning4j-core/src/main/java/org/deeplearning4j/api/storage/impl/RemoteUIStatsStorageRouter.java index 439e87eb7..1e4c62c3c 100644 --- a/deeplearning4j/deeplearning4j-core/src/main/java/org/deeplearning4j/api/storage/impl/RemoteUIStatsStorageRouter.java +++ b/deeplearning4j/deeplearning4j-core/src/main/java/org/deeplearning4j/api/storage/impl/RemoteUIStatsStorageRouter.java @@ -43,7 +43,8 @@ import java.util.concurrent.atomic.AtomicLong; */ @Slf4j public class RemoteUIStatsStorageRouter implements StatsStorageRouter, Serializable, Closeable { - + private static final String ROUTE_IS_DOWN = "Info posted to RemoteUIStatsStorageRouter but router is shut down."; + private static final String MAX_WARNINGS_REACHED = "RemoteUIStatsStorageRouter: Reached max shutdown warnings. No further warnings will be produced."; /** * Default path for posting data to the UI - i.e., http://localhost:9000/remoteReceive or similar */ @@ -163,10 +164,10 @@ public class RemoteUIStatsStorageRouter implements StatsStorageRouter, Serializa if (shutdown.get()) { long count = shutdownWarnCount.getAndIncrement(); if (count <= MAX_SHUTDOWN_WARN_COUNT) { - log.warn("Info posted to RemoteUIStatsStorageRouter but router is shut down."); + log.warn(ROUTE_IS_DOWN); } if (count == MAX_SHUTDOWN_WARN_COUNT) { - log.warn("RemoteUIStatsStorageRouter: Reached max shutdown warnings. No further warnings will be produced."); + log.warn(MAX_WARNINGS_REACHED); } } else { for (StorageMetaData m : storageMetaData) { @@ -186,10 +187,10 @@ public class RemoteUIStatsStorageRouter implements StatsStorageRouter, Serializa if (shutdown.get()) { long count = shutdownWarnCount.getAndIncrement(); if (count <= MAX_SHUTDOWN_WARN_COUNT) { - log.warn("Info posted to RemoteUIStatsStorageRouter but router is shut down."); + log.warn(ROUTE_IS_DOWN); } if (count == MAX_SHUTDOWN_WARN_COUNT) { - log.warn("RemoteUIStatsStorageRouter: Reached max shutdown warnings. No further warnings will be produced."); + log.warn(MAX_WARNINGS_REACHED); } } else { for (Persistable p : staticInfo) { @@ -209,10 +210,10 @@ public class RemoteUIStatsStorageRouter implements StatsStorageRouter, Serializa if (shutdown.get()) { long count = shutdownWarnCount.getAndIncrement(); if (count <= MAX_SHUTDOWN_WARN_COUNT) { - log.warn("Info posted to RemoteUIStatsStorageRouter but router is shut down."); + log.warn(ROUTE_IS_DOWN); } if (count == MAX_SHUTDOWN_WARN_COUNT) { - log.warn("RemoteUIStatsStorageRouter: Reached max shutdown warnings. No further warnings will be produced."); + log.warn(MAX_WARNINGS_REACHED); } } else { for (Persistable p : updates) { diff --git a/deeplearning4j/deeplearning4j-core/src/main/java/org/deeplearning4j/parallelism/AsyncIterator.java b/deeplearning4j/deeplearning4j-core/src/main/java/org/deeplearning4j/parallelism/AsyncIterator.java index 154934b7e..b2d3e1169 100644 --- a/deeplearning4j/deeplearning4j-core/src/main/java/org/deeplearning4j/parallelism/AsyncIterator.java +++ b/deeplearning4j/deeplearning4j-core/src/main/java/org/deeplearning4j/parallelism/AsyncIterator.java @@ -67,10 +67,7 @@ public class AsyncIterator implements Iterator { nextElement = buffer.take(); // same on this run - if (nextElement == terminator) - return false; - - return true; + return (nextElement != terminator); } catch (Exception e) { log.error("Premature end of loop!"); return false; diff --git a/deeplearning4j/deeplearning4j-core/src/main/java/org/deeplearning4j/perf/listener/SystemInfoPrintListener.java b/deeplearning4j/deeplearning4j-core/src/main/java/org/deeplearning4j/perf/listener/SystemInfoPrintListener.java index 7bdb3491c..dc9981535 100644 --- a/deeplearning4j/deeplearning4j-core/src/main/java/org/deeplearning4j/perf/listener/SystemInfoPrintListener.java +++ b/deeplearning4j/deeplearning4j-core/src/main/java/org/deeplearning4j/perf/listener/SystemInfoPrintListener.java @@ -43,7 +43,7 @@ public class SystemInfoPrintListener implements TrainingListener { private boolean printOnBackwardPass; private boolean printOnGradientCalculation; - + private static final String SYSTEM_INFO = "System info on epoch end: "; @Override public void iterationDone(Model model, int iteration, int epoch) { @@ -65,7 +65,7 @@ public class SystemInfoPrintListener implements TrainingListener { return; SystemInfo systemInfo = new SystemInfo(); - log.info("System info on epoch end: "); + log.info(SYSTEM_INFO); log.info(systemInfo.toPrettyJSON()); } @@ -75,7 +75,7 @@ public class SystemInfoPrintListener implements TrainingListener { return; SystemInfo systemInfo = new SystemInfo(); - log.info("System info on epoch end: "); + log.info(SYSTEM_INFO); log.info(systemInfo.toPrettyJSON()); } @@ -85,7 +85,7 @@ public class SystemInfoPrintListener implements TrainingListener { return; SystemInfo systemInfo = new SystemInfo(); - log.info("System info on epoch end: "); + log.info(SYSTEM_INFO); log.info(systemInfo.toPrettyJSON()); } @@ -95,7 +95,7 @@ public class SystemInfoPrintListener implements TrainingListener { return; SystemInfo systemInfo = new SystemInfo(); - log.info("System info on epoch end: "); + log.info(SYSTEM_INFO); log.info(systemInfo.toPrettyJSON()); } @@ -104,7 +104,7 @@ public class SystemInfoPrintListener implements TrainingListener { if(!printOnBackwardPass) return; SystemInfo systemInfo = new SystemInfo(); - log.info("System info on epoch end: "); + log.info(SYSTEM_INFO); log.info(systemInfo.toPrettyJSON()); } } diff --git a/deeplearning4j/deeplearning4j-core/src/main/java/org/deeplearning4j/perf/listener/SystemPolling.java b/deeplearning4j/deeplearning4j-core/src/main/java/org/deeplearning4j/perf/listener/SystemPolling.java index 4813bcf73..323f6e96e 100644 --- a/deeplearning4j/deeplearning4j-core/src/main/java/org/deeplearning4j/perf/listener/SystemPolling.java +++ b/deeplearning4j/deeplearning4j-core/src/main/java/org/deeplearning4j/perf/listener/SystemPolling.java @@ -16,6 +16,7 @@ package org.deeplearning4j.perf.listener; +import lombok.extern.slf4j.Slf4j; import org.nd4j.shade.jackson.databind.ObjectMapper; import org.nd4j.shade.jackson.dataformat.yaml.YAMLFactory; import oshi.json.SystemInfo; @@ -36,6 +37,7 @@ import java.util.concurrent.TimeUnit; * * @author Adam Gibson */ +@Slf4j public class SystemPolling { private ScheduledExecutorService scheduledExecutorService; @@ -66,7 +68,7 @@ public class SystemPolling { try { objectMapper.writeValue(hardwareFile,hardwareMetric); } catch (IOException e) { - e.printStackTrace(); + log.error("",e); } } },0,pollEveryMillis, TimeUnit.MILLISECONDS); diff --git a/deeplearning4j/deeplearning4j-core/src/main/java/org/deeplearning4j/util/ModelGuesser.java b/deeplearning4j/deeplearning4j-core/src/main/java/org/deeplearning4j/util/ModelGuesser.java index 96e29d1ac..ed2d146cc 100644 --- a/deeplearning4j/deeplearning4j-core/src/main/java/org/deeplearning4j/util/ModelGuesser.java +++ b/deeplearning4j/deeplearning4j-core/src/main/java/org/deeplearning4j/util/ModelGuesser.java @@ -27,7 +27,6 @@ import org.deeplearning4j.nn.modelimport.keras.KerasModelImport; import org.nd4j.linalg.dataset.api.preprocessor.Normalizer; import java.io.*; -import java.nio.file.Files; import java.util.UUID; /** diff --git a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/datasets/datavec/RecordReaderDataSetiteratorTest.java b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/datasets/datavec/RecordReaderDataSetiteratorTest.java index 2b7121af4..7e073b22e 100644 --- a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/datasets/datavec/RecordReaderDataSetiteratorTest.java +++ b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/datasets/datavec/RecordReaderDataSetiteratorTest.java @@ -493,7 +493,7 @@ public class RecordReaderDataSetiteratorTest extends BaseDL4JTest { out.println(); } } catch (IOException e) { - e.printStackTrace(); + log.error("",e); } return new Pair<>(dArr,temp); diff --git a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/datasets/iterator/EarlyTerminationDataSetIteratorTest.java b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/datasets/iterator/EarlyTerminationDataSetIteratorTest.java index 145a12773..19b56679c 100644 --- a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/datasets/iterator/EarlyTerminationDataSetIteratorTest.java +++ b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/datasets/iterator/EarlyTerminationDataSetIteratorTest.java @@ -78,10 +78,10 @@ public class EarlyTerminationDataSetIteratorTest extends BaseDL4JTest { EarlyTerminationDataSetIterator earlyEndIter = new EarlyTerminationDataSetIterator(iter, terminateAfter); earlyEndIter.next(10); - assertEquals(earlyEndIter.hasNext(), false); + assertEquals(false, earlyEndIter.hasNext()); earlyEndIter.reset(); - assertEquals(earlyEndIter.hasNext(), true); + assertEquals(true, earlyEndIter.hasNext()); } diff --git a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/datasets/iterator/MultipleEpochsIteratorTest.java b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/datasets/iterator/MultipleEpochsIteratorTest.java index f37642c24..10a4285a1 100644 --- a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/datasets/iterator/MultipleEpochsIteratorTest.java +++ b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/datasets/iterator/MultipleEpochsIteratorTest.java @@ -98,7 +98,7 @@ public class MultipleEpochsIteratorTest extends BaseDL4JTest { while (multiIter.hasNext()) { DataSet path = multiIter.next(10); assertNotNull(path); - assertEquals(path.numExamples(), 10, 0.0); + assertEquals(10, path.numExamples(), 0.0); } assertEquals(epochs, multiIter.epochs); diff --git a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/datasets/iterator/SamplingTest.java b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/datasets/iterator/SamplingTest.java index 5b159a015..fa8f20662 100644 --- a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/datasets/iterator/SamplingTest.java +++ b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/datasets/iterator/SamplingTest.java @@ -33,7 +33,7 @@ public class SamplingTest extends BaseDL4JTest { DataSetIterator iter = new MnistDataSetIterator(10, 10); //batch size and total DataSetIterator sampling = new SamplingDataSetIterator(iter.next(), 10, 10); - assertEquals(sampling.next().numExamples(), 10); + assertEquals(10, sampling.next().numExamples()); } } diff --git a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/exceptions/TestInvalidConfigurations.java b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/exceptions/TestInvalidConfigurations.java index f036d780a..0ea7ff282 100644 --- a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/exceptions/TestInvalidConfigurations.java +++ b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/exceptions/TestInvalidConfigurations.java @@ -16,6 +16,7 @@ package org.deeplearning4j.exceptions; +import lombok.extern.slf4j.Slf4j; import org.deeplearning4j.BaseDL4JTest; import org.deeplearning4j.exception.DL4JException; import org.deeplearning4j.nn.conf.ConvolutionMode; @@ -34,6 +35,7 @@ import static org.junit.Assert.fail; /** * A set of tests to ensure that useful exceptions are thrown on invalid network configurations */ +@Slf4j public class TestInvalidConfigurations extends BaseDL4JTest { public static MultiLayerNetwork getDensePlusOutput(int nIn, int nOut) { @@ -78,7 +80,7 @@ public class TestInvalidConfigurations extends BaseDL4JTest { } catch (DL4JException e) { System.out.println("testDenseNin0(): " + e.getMessage()); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); fail(); } } @@ -96,7 +98,7 @@ public class TestInvalidConfigurations extends BaseDL4JTest { } catch (DL4JException e) { System.out.println("testDenseNout0(): " + e.getMessage()); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); fail(); } } @@ -109,7 +111,7 @@ public class TestInvalidConfigurations extends BaseDL4JTest { } catch (DL4JException e) { System.out.println("testOutputLayerNin0(): " + e.getMessage()); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); fail(); } } @@ -122,7 +124,7 @@ public class TestInvalidConfigurations extends BaseDL4JTest { } catch (DL4JException e) { System.out.println("testRnnOutputLayerNin0(): " + e.getMessage()); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); fail(); } } @@ -135,7 +137,7 @@ public class TestInvalidConfigurations extends BaseDL4JTest { } catch (DL4JException e) { System.out.println("testLSTMNIn0(): " + e.getMessage()); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); fail(); } } @@ -153,7 +155,7 @@ public class TestInvalidConfigurations extends BaseDL4JTest { } catch (DL4JException e) { System.out.println("testLSTMNOut0(): " + e.getMessage()); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); fail(); } } @@ -166,7 +168,7 @@ public class TestInvalidConfigurations extends BaseDL4JTest { } catch (DL4JException e) { System.out.println("testConvolutionalNin0(): " + e.getMessage()); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); fail(); } } @@ -185,7 +187,7 @@ public class TestInvalidConfigurations extends BaseDL4JTest { } catch (DL4JException e) { System.out.println("testConvolutionalNOut0(): " + e.getMessage()); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); fail(); } } @@ -216,7 +218,7 @@ public class TestInvalidConfigurations extends BaseDL4JTest { } catch (DL4JException e) { System.out.println("testCnnInvalidConfigPaddingStridesHeight(): " + e.getMessage()); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); fail(); } } @@ -245,7 +247,7 @@ public class TestInvalidConfigurations extends BaseDL4JTest { } catch (DL4JException e) { System.out.println("testCnnInvalidConfigOrInput_SmallerDataThanKernel(): " + e.getMessage()); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); fail(); } } @@ -277,7 +279,7 @@ public class TestInvalidConfigurations extends BaseDL4JTest { } catch (DL4JException e) { System.out.println("testCnnInvalidConfigOrInput_BadStrides(): " + e.getMessage()); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); fail(); } } @@ -318,7 +320,7 @@ public class TestInvalidConfigurations extends BaseDL4JTest { } catch (DL4JException e) { System.out.println("testCnnInvalidConfigPaddingStridesWidth(): " + e.getMessage()); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); fail(); } } @@ -347,7 +349,7 @@ public class TestInvalidConfigurations extends BaseDL4JTest { } catch (DL4JException e) { System.out.println("testCnnInvalidConfigPaddingStridesWidthSubsampling(): " + e.getMessage()); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); fail(); } } diff --git a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/exceptions/TestInvalidInput.java b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/exceptions/TestInvalidInput.java index 096c7ac69..49c65e2c8 100644 --- a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/exceptions/TestInvalidInput.java +++ b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/exceptions/TestInvalidInput.java @@ -16,6 +16,7 @@ package org.deeplearning4j.exceptions; +import lombok.extern.slf4j.Slf4j; import org.deeplearning4j.BaseDL4JTest; import org.deeplearning4j.exception.DL4JException; import org.deeplearning4j.nn.conf.MultiLayerConfiguration; @@ -36,6 +37,7 @@ import static org.junit.Assert.*; /** * A set of tests to ensure that useful exceptions are thrown on invalid input */ +@Slf4j public class TestInvalidInput extends BaseDL4JTest { @Test @@ -53,7 +55,7 @@ public class TestInvalidInput extends BaseDL4JTest { } catch (DL4JException e) { System.out.println("testInputNinMismatchDense(): " + e.getMessage()); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); fail("Expected DL4JException"); } } @@ -73,7 +75,7 @@ public class TestInvalidInput extends BaseDL4JTest { } catch (DL4JException e) { System.out.println("testInputNinMismatchOutputLayer(): " + e.getMessage()); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); fail("Expected DL4JException"); } } @@ -94,7 +96,7 @@ public class TestInvalidInput extends BaseDL4JTest { //From loss function System.out.println("testLabelsNOutMismatchOutputLayer(): " + e.getMessage()); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); fail("Expected DL4JException"); } } @@ -115,7 +117,7 @@ public class TestInvalidInput extends BaseDL4JTest { //From loss function System.out.println("testLabelsNOutMismatchRnnOutputLayer(): " + e.getMessage()); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); fail("Expected DL4JException"); } } @@ -142,7 +144,7 @@ public class TestInvalidInput extends BaseDL4JTest { } catch (DL4JException e) { System.out.println("testInputNinMismatchConvolutional(): " + e.getMessage()); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); fail("Expected DL4JException"); } } @@ -169,7 +171,7 @@ public class TestInvalidInput extends BaseDL4JTest { } catch (DL4JException e) { System.out.println("testInputNinRank2Convolutional(): " + e.getMessage()); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); fail("Expected DL4JException"); } } @@ -195,7 +197,7 @@ public class TestInvalidInput extends BaseDL4JTest { } catch (DL4JException e) { System.out.println("testInputNinRank2Subsampling(): " + e.getMessage()); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); fail("Expected DL4JException"); } } @@ -217,7 +219,7 @@ public class TestInvalidInput extends BaseDL4JTest { } catch (DL4JException e) { System.out.println("testInputNinMismatchLSTM(): " + e.getMessage()); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); fail("Expected DL4JException"); } } @@ -238,7 +240,7 @@ public class TestInvalidInput extends BaseDL4JTest { } catch (DL4JException e) { System.out.println("testInputNinMismatchBidirectionalLSTM(): " + e.getMessage()); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); fail("Expected DL4JException"); } @@ -260,7 +262,7 @@ public class TestInvalidInput extends BaseDL4JTest { } catch (DL4JException e) { System.out.println("testInputNinMismatchEmbeddingLayer(): " + e.getMessage()); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); fail("Expected DL4JException"); } } @@ -305,7 +307,7 @@ public class TestInvalidInput extends BaseDL4JTest { net.rnnTimeStep(Nd4j.create(5, 5, 10)); fail("Expected Exception - " + layerType); } catch (Exception e) { -// e.printStackTrace(); + log.error("",e); String msg = e.getMessage(); assertTrue(msg, msg != null && msg.contains("rnn") && msg.contains("batch")); } diff --git a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/gradientcheck/LossFunctionGradientCheck.java b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/gradientcheck/LossFunctionGradientCheck.java index e67f03f50..ab6c8215a 100644 --- a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/gradientcheck/LossFunctionGradientCheck.java +++ b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/gradientcheck/LossFunctionGradientCheck.java @@ -216,7 +216,7 @@ public class LossFunctionGradientCheck extends BaseDL4JTest { gradOK = GradientCheckUtil.checkGradients(net, DEFAULT_EPS, DEFAULT_MAX_REL_ERROR, DEFAULT_MIN_ABS_ERROR, PRINT_RESULTS, RETURN_ON_FIRST_FAILURE, input, labels); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); failed.add(testName + "\t" + "EXCEPTION"); continue; } @@ -383,7 +383,7 @@ public class LossFunctionGradientCheck extends BaseDL4JTest { gradOK = GradientCheckUtil.checkGradients(net, DEFAULT_EPS, DEFAULT_MAX_REL_ERROR, DEFAULT_MIN_ABS_ERROR, PRINT_RESULTS, RETURN_ON_FIRST_FAILURE, input, labels); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); failed.add(testName + "\t" + "EXCEPTION"); continue; } @@ -693,7 +693,7 @@ public class LossFunctionGradientCheck extends BaseDL4JTest { gradOK = GradientCheckUtil.checkGradients(net, DEFAULT_EPS, DEFAULT_MAX_REL_ERROR, DEFAULT_MIN_ABS_ERROR, PRINT_RESULTS, RETURN_ON_FIRST_FAILURE, input, labels); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); failed.add(testName + "\t" + "EXCEPTION"); continue; } diff --git a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/conf/ComputationGraphConfigurationTest.java b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/conf/ComputationGraphConfigurationTest.java index cf972bac3..b6adf538c 100644 --- a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/conf/ComputationGraphConfigurationTest.java +++ b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/conf/ComputationGraphConfigurationTest.java @@ -21,6 +21,7 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.deeplearning4j.BaseDL4JTest; import org.deeplearning4j.exception.DL4JInvalidConfigException; import org.deeplearning4j.nn.api.OptimizationAlgorithm; @@ -47,6 +48,7 @@ import org.nd4j.linalg.lossfunctions.LossFunctions; import static org.junit.Assert.*; +@Slf4j public class ComputationGraphConfigurationTest extends BaseDL4JTest { @Test @@ -150,7 +152,7 @@ public class ComputationGraphConfigurationTest extends BaseDL4JTest { fail("No exception thrown for invalid configuration"); } catch (IllegalStateException e) { //OK - exception is good - //e.printStackTrace(); + log.info(e.toString()); } // Use appendLayer on first layer @@ -162,7 +164,7 @@ public class ComputationGraphConfigurationTest extends BaseDL4JTest { fail("No exception thrown for invalid configuration"); } catch (IllegalStateException e) { //OK - exception is good - //e.printStackTrace(); + log.info(e.toString()); } //Test no network inputs @@ -174,7 +176,7 @@ public class ComputationGraphConfigurationTest extends BaseDL4JTest { fail("No exception thrown for invalid configuration"); } catch (IllegalStateException e) { //OK - exception is good - //e.printStackTrace(); + log.info(e.toString()); } //Test no network outputs @@ -185,7 +187,7 @@ public class ComputationGraphConfigurationTest extends BaseDL4JTest { fail("No exception thrown for invalid configuration"); } catch (IllegalStateException e) { //OK - exception is good - //e.printStackTrace(); + log.info(e.toString()); } //Test: invalid input @@ -197,7 +199,7 @@ public class ComputationGraphConfigurationTest extends BaseDL4JTest { fail("No exception thrown for invalid configuration"); } catch (IllegalStateException e) { //OK - exception is good - //e.printStackTrace(); + log.info(e.toString()); } //Test: graph with cycles @@ -215,7 +217,7 @@ public class ComputationGraphConfigurationTest extends BaseDL4JTest { fail("No exception thrown for invalid configuration"); } catch (IllegalStateException e) { //OK - exception is good - //e.printStackTrace(); + log.info(e.toString()); } //Test: input != inputType count mismatch @@ -241,7 +243,7 @@ public class ComputationGraphConfigurationTest extends BaseDL4JTest { fail("No exception thrown for invalid configuration"); } catch (IllegalArgumentException e) { //OK - exception is good - //e.printStackTrace(); + log.info(e.toString()); } } diff --git a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/conf/MultiLayerNeuralNetConfigurationTest.java b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/conf/MultiLayerNeuralNetConfigurationTest.java index 5de2bb2dc..9e187c9db 100644 --- a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/conf/MultiLayerNeuralNetConfigurationTest.java +++ b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/conf/MultiLayerNeuralNetConfigurationTest.java @@ -16,6 +16,7 @@ package org.deeplearning4j.nn.conf; +import lombok.extern.slf4j.Slf4j; import org.deeplearning4j.BaseDL4JTest; import org.deeplearning4j.exception.DL4JInvalidConfigException; import org.deeplearning4j.nn.api.Layer; @@ -46,6 +47,7 @@ import static org.junit.Assert.*; /** * Created by agibsonccc on 11/27/14. */ +@Slf4j public class MultiLayerNeuralNetConfigurationTest extends BaseDL4JTest { @Rule @@ -272,9 +274,9 @@ public class MultiLayerNeuralNetConfigurationTest extends BaseDL4JTest { fail("No exception thrown for invalid configuration"); } catch (IllegalStateException e) { //OK - e.printStackTrace(); + log.error("",e); } catch (Throwable e) { - e.printStackTrace(); + log.error("",e); fail("Unexpected exception thrown for invalid config"); } @@ -288,9 +290,9 @@ public class MultiLayerNeuralNetConfigurationTest extends BaseDL4JTest { fail("No exception thrown for invalid configuration"); } catch (IllegalStateException e) { //OK - e.printStackTrace(); + log.info(e.toString()); } catch (Throwable e) { - e.printStackTrace(); + log.error("",e); fail("Unexpected exception thrown for invalid config"); } @@ -304,9 +306,9 @@ public class MultiLayerNeuralNetConfigurationTest extends BaseDL4JTest { fail("No exception thrown for invalid configuration"); } catch (IllegalStateException e) { //OK - e.printStackTrace(); + log.info(e.toString()); } catch (Throwable e) { - e.printStackTrace(); + log.error("",e); fail("Unexpected exception thrown for invalid config"); } } diff --git a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/conf/constraints/TestConstraints.java b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/conf/constraints/TestConstraints.java index 1445364fe..0db6a1357 100644 --- a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/conf/constraints/TestConstraints.java +++ b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/conf/constraints/TestConstraints.java @@ -96,8 +96,8 @@ public class TestConstraints extends BaseDL4JTest { } else if (lc instanceof NonNegativeConstraint) { assertTrue(RW0.minNumber().doubleValue() >= 0.0); } else if (lc instanceof UnitNormConstraint) { - assertEquals(RW0.norm2(1).minNumber().doubleValue(), 1.0, 1e-6); - assertEquals(RW0.norm2(1).maxNumber().doubleValue(), 1.0, 1e-6); + assertEquals(1.0, RW0.norm2(1).minNumber().doubleValue(), 1e-6); + assertEquals(1.0, RW0.norm2(1).maxNumber().doubleValue(), 1e-6); } TestUtils.testModelSerialization(net); @@ -149,8 +149,8 @@ public class TestConstraints extends BaseDL4JTest { } else if (lc instanceof NonNegativeConstraint) { assertTrue(b0.minNumber().doubleValue() >= 0.0); } else if (lc instanceof UnitNormConstraint) { - assertEquals(b0.norm2(1).minNumber().doubleValue(), 1.0, 1e-6); - assertEquals(b0.norm2(1).maxNumber().doubleValue(), 1.0, 1e-6); + assertEquals(1.0, b0.norm2(1).minNumber().doubleValue(), 1e-6); + assertEquals(1.0, b0.norm2(1).maxNumber().doubleValue(), 1e-6); } TestUtils.testModelSerialization(net); @@ -201,8 +201,8 @@ public class TestConstraints extends BaseDL4JTest { } else if (lc instanceof NonNegativeConstraint) { assertTrue(w0.minNumber().doubleValue() >= 0.0); } else if (lc instanceof UnitNormConstraint) { - assertEquals(w0.norm2(1).minNumber().doubleValue(), 1.0, 1e-6); - assertEquals(w0.norm2(1).maxNumber().doubleValue(), 1.0, 1e-6); + assertEquals(1.0, w0.norm2(1).minNumber().doubleValue(), 1e-6); + assertEquals(1.0, w0.norm2(1).maxNumber().doubleValue(), 1e-6); } TestUtils.testModelSerialization(net); @@ -259,10 +259,10 @@ public class TestConstraints extends BaseDL4JTest { assertTrue(w0.minNumber().doubleValue() >= 0.0); assertTrue(b0.minNumber().doubleValue() >= 0.0); } else if (lc instanceof UnitNormConstraint) { - assertEquals(w0.norm2(1).minNumber().doubleValue(), 1.0, 1e-6); - assertEquals(w0.norm2(1).maxNumber().doubleValue(), 1.0, 1e-6); - assertEquals(b0.norm2(1).minNumber().doubleValue(), 1.0, 1e-6); - assertEquals(b0.norm2(1).maxNumber().doubleValue(), 1.0, 1e-6); + assertEquals(1.0, w0.norm2(1).minNumber().doubleValue(), 1e-6); + assertEquals(1.0, w0.norm2(1).maxNumber().doubleValue(), 1e-6); + assertEquals(1.0, b0.norm2(1).minNumber().doubleValue(), 1e-6); + assertEquals(1.0, b0.norm2(1).maxNumber().doubleValue(), 1e-6); } TestUtils.testModelSerialization(net); @@ -320,10 +320,10 @@ public class TestConstraints extends BaseDL4JTest { assertTrue(w0.minNumber().doubleValue() >= 0.0); assertTrue(b0.minNumber().doubleValue() >= 0.0); } else if (lc instanceof UnitNormConstraint) { - assertEquals(w0.norm2(1).minNumber().doubleValue(), 1.0, 1e-6); - assertEquals(w0.norm2(1).maxNumber().doubleValue(), 1.0, 1e-6); - assertEquals(b0.norm2(1).minNumber().doubleValue(), 1.0, 1e-6); - assertEquals(b0.norm2(1).maxNumber().doubleValue(), 1.0, 1e-6); + assertEquals(1.0, w0.norm2(1).minNumber().doubleValue(), 1e-6); + assertEquals(1.0, w0.norm2(1).maxNumber().doubleValue(), 1e-6); + assertEquals(1.0, b0.norm2(1).minNumber().doubleValue(), 1e-6); + assertEquals(1.0, b0.norm2(1).maxNumber().doubleValue(), 1e-6); } TestUtils.testModelSerialization(net); @@ -378,10 +378,10 @@ public class TestConstraints extends BaseDL4JTest { } else if(lc instanceof NonNegativeConstraint ){ assertTrue(w0.minNumber().doubleValue() >= 0.0 ); } else if(lc instanceof UnitNormConstraint ){ - assertEquals(w0.norm2(1).minNumber().doubleValue(), 1.0, 1e-6 ); - assertEquals(w0.norm2(1).maxNumber().doubleValue(), 1.0, 1e-6 ); - assertEquals(w1.norm2(1).minNumber().doubleValue(), 1.0, 1e-6 ); - assertEquals(w1.norm2(1).maxNumber().doubleValue(), 1.0, 1e-6 ); + assertEquals(1.0, w0.norm2(1).minNumber().doubleValue(), 1e-6 ); + assertEquals(1.0, w0.norm2(1).maxNumber().doubleValue(), 1e-6 ); + assertEquals(1.0, w1.norm2(1).minNumber().doubleValue(), 1e-6 ); + assertEquals(1.0, w1.norm2(1).maxNumber().doubleValue(), 1e-6 ); } TestUtils.testModelSerialization(net); diff --git a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/conf/layers/LayerBuilderTest.java b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/conf/layers/LayerBuilderTest.java index 1288b1078..12f5a8e0d 100644 --- a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/conf/layers/LayerBuilderTest.java +++ b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/conf/layers/LayerBuilderTest.java @@ -156,7 +156,7 @@ public class LayerBuilderTest extends BaseDL4JTest { checkSerialization(glstm); - assertEquals(glstm.getForgetGateBiasInit(), 1.5, 0.0); + assertEquals(1.5, glstm.getForgetGateBiasInit(), 0.0); assertEquals(glstm.nIn, numIn); assertEquals(glstm.nOut, numOut); assertTrue(glstm.getActivationFn() instanceof ActivationTanH); diff --git a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/graph/ComputationGraphTestRNN.java b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/graph/ComputationGraphTestRNN.java index ff6ff2da2..a6778626f 100644 --- a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/graph/ComputationGraphTestRNN.java +++ b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/graph/ComputationGraphTestRNN.java @@ -16,6 +16,7 @@ package org.deeplearning4j.nn.graph; +import lombok.extern.slf4j.Slf4j; import lombok.val; import org.deeplearning4j.BaseDL4JTest; import org.deeplearning4j.datasets.iterator.IteratorDataSetIterator; @@ -54,6 +55,7 @@ import java.util.Map; import static org.junit.Assert.*; +@Slf4j public class ComputationGraphTestRNN extends BaseDL4JTest { @Test @@ -618,7 +620,7 @@ public class ComputationGraphTestRNN extends BaseDL4JTest { .build(); fail("Exception expected"); } catch (IllegalStateException e){ -// e.printStackTrace(); + log.error("",e); assertTrue(e.getMessage().contains("TBPTT") && e.getMessage().contains("validateTbpttConfig")); } } diff --git a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/graph/TestComputationGraphNetwork.java b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/graph/TestComputationGraphNetwork.java index 28bc42983..7ba76894d 100644 --- a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/graph/TestComputationGraphNetwork.java +++ b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/graph/TestComputationGraphNetwork.java @@ -1394,7 +1394,7 @@ public class TestComputationGraphNetwork extends BaseDL4JTest { } catch (Exception e) { - //e.printStackTrace(); + log.error("",e); if(allowDisconnected){ fail("No exception expected"); } else { diff --git a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/graph/TestVariableLengthTSCG.java b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/graph/TestVariableLengthTSCG.java index f249acafc..05025fde5 100644 --- a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/graph/TestVariableLengthTSCG.java +++ b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/graph/TestVariableLengthTSCG.java @@ -416,8 +416,8 @@ public class TestVariableLengthTSCG extends BaseDL4JTest { INDArray outRow2 = out2.get(NDArrayIndex.point(i), NDArrayIndex.all(), NDArrayIndex.point(j)); for (int k = 0; k < nOut; k++) { - assertEquals(outRow.getDouble(k), 0.0, 0.0); - assertEquals(outRow2.getDouble(k), 0.0, 0.0); + assertEquals(0.0, outRow.getDouble(k), 0.0); + assertEquals(0.0, outRow2.getDouble(k), 0.0); } } } diff --git a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/layers/convolution/TestConvolutionModes.java b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/layers/convolution/TestConvolutionModes.java index 037640ebb..0f5b5d6d1 100644 --- a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/layers/convolution/TestConvolutionModes.java +++ b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/layers/convolution/TestConvolutionModes.java @@ -16,6 +16,7 @@ package org.deeplearning4j.nn.layers.convolution; +import lombok.extern.slf4j.Slf4j; import org.deeplearning4j.BaseDL4JTest; import org.deeplearning4j.exception.DL4JException; import org.deeplearning4j.nn.conf.ComputationGraphConfiguration; @@ -45,6 +46,7 @@ import static org.junit.Assert.*; /** * Created by Alex on 15/11/2016. */ +@Slf4j public class TestConvolutionModes extends BaseDL4JTest { @Test @@ -106,12 +108,12 @@ public class TestConvolutionModes extends BaseDL4JTest { } } catch (DL4JException e) { if (inSize == 9 || cm != ConvolutionMode.Strict) { - e.printStackTrace(); + log.error("",e); fail("Unexpected exception"); } continue; //Expected exception } catch (Exception e) { - e.printStackTrace(); + log.error("",e); fail("Unexpected exception"); } @@ -184,12 +186,12 @@ public class TestConvolutionModes extends BaseDL4JTest { } } catch (DL4JException e) { if (inSize == 9 || cm != ConvolutionMode.Strict) { - e.printStackTrace(); + log.error("",e); fail("Unexpected exception"); } continue; //Expected exception } catch (Exception e) { - e.printStackTrace(); + log.error("",e); fail("Unexpected exception"); } diff --git a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/layers/recurrent/MaskZeroLayerTest.java b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/layers/recurrent/MaskZeroLayerTest.java index d13545694..3ed7e1f3b 100644 --- a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/layers/recurrent/MaskZeroLayerTest.java +++ b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/layers/recurrent/MaskZeroLayerTest.java @@ -79,13 +79,13 @@ public class MaskZeroLayerTest extends BaseDL4JTest { INDArray firstExampleOutput = out.get(NDArrayIndex.point(0), NDArrayIndex.all(), NDArrayIndex.all()); INDArray secondExampleOutput = out.get(NDArrayIndex.point(1), NDArrayIndex.all(), NDArrayIndex.all()); - assertEquals(firstExampleOutput.getDouble(0), 0.0, 1e-6); - assertEquals(firstExampleOutput.getDouble(1), 1.0, 1e-6); - assertEquals(firstExampleOutput.getDouble(2), 2.0, 1e-6); + assertEquals(0.0, firstExampleOutput.getDouble(0), 1e-6); + assertEquals(1.0, firstExampleOutput.getDouble(1), 1e-6); + assertEquals(2.0, firstExampleOutput.getDouble(2), 1e-6); - assertEquals(secondExampleOutput.getDouble(0), 0.0, 1e-6); - assertEquals(secondExampleOutput.getDouble(1), 0.0, 1e-6); - assertEquals(secondExampleOutput.getDouble(2), 1.0, 1e-6); + assertEquals(0.0, secondExampleOutput.getDouble(0), 1e-6); + assertEquals(0.0, secondExampleOutput.getDouble(1), 1e-6); + assertEquals(1.0, secondExampleOutput.getDouble(2), 1e-6); } diff --git a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/multilayer/MultiLayerTestRNN.java b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/multilayer/MultiLayerTestRNN.java index 5da79bc58..0c25ce7e3 100644 --- a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/multilayer/MultiLayerTestRNN.java +++ b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/multilayer/MultiLayerTestRNN.java @@ -771,7 +771,7 @@ public class MultiLayerTestRNN extends BaseDL4JTest { .build(); fail("Exception expected"); } catch (IllegalStateException e){ -// e.printStackTrace(); + log.info(e.toString()); assertTrue(e.getMessage().contains("TBPTT") && e.getMessage().contains("validateTbpttConfig")); } } diff --git a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/multilayer/TestVariableLengthTS.java b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/multilayer/TestVariableLengthTS.java index 2feb7792c..ad0fd9884 100644 --- a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/multilayer/TestVariableLengthTS.java +++ b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/multilayer/TestVariableLengthTS.java @@ -408,8 +408,8 @@ public class TestVariableLengthTS extends BaseDL4JTest { INDArray outRow2 = out2.get(NDArrayIndex.point(i), NDArrayIndex.all(), NDArrayIndex.point(j)); for (int k = 0; k < nOut; k++) { - assertEquals(outRow.getDouble(k), 0.0, 0.0); - assertEquals(outRow2.getDouble(k), 0.0, 0.0); + assertEquals(0.0, outRow.getDouble(k), 0.0); + assertEquals(0.0, outRow2.getDouble(k), 0.0); } } } diff --git a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/updater/TestUpdaters.java b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/updater/TestUpdaters.java index 0a17441bc..ccf698481 100644 --- a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/updater/TestUpdaters.java +++ b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/nn/updater/TestUpdaters.java @@ -336,7 +336,7 @@ public class TestUpdaters extends BaseDL4JTest { actualM[i] = Math.round(actualM[i] * 1e2) / 1e2; } - assertEquals("Wrong weight gradient after first iteration's update", Arrays.equals(actualM, expectedM), true); + assertEquals("Wrong weight gradient after first iteration's update", Arrays.equals(expectedM, actualM), true); } diff --git a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/regressiontest/RegressionTest050.java b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/regressiontest/RegressionTest050.java index 867e96f09..c76a9fbbe 100644 --- a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/regressiontest/RegressionTest050.java +++ b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/regressiontest/RegressionTest050.java @@ -159,14 +159,14 @@ public class RegressionTest050 extends BaseDL4JTest { assertArrayEquals(new int[] {2, 2}, l0.getKernelSize()); assertArrayEquals(new int[] {1, 1}, l0.getStride()); assertArrayEquals(new int[] {0, 0}, l0.getPadding()); - assertEquals(l0.getConvolutionMode(), ConvolutionMode.Truncate); //Pre-0.7.0: no ConvolutionMode. Want to default to truncate here if not set + assertEquals(ConvolutionMode.Truncate, l0.getConvolutionMode()); //Pre-0.7.0: no ConvolutionMode. Want to default to truncate here if not set SubsamplingLayer l1 = (SubsamplingLayer) conf.getConf(1).getLayer(); assertArrayEquals(new int[] {2, 2}, l1.getKernelSize()); assertArrayEquals(new int[] {1, 1}, l1.getStride()); assertArrayEquals(new int[] {0, 0}, l1.getPadding()); assertEquals(PoolingType.MAX, l1.getPoolingType()); - assertEquals(l1.getConvolutionMode(), ConvolutionMode.Truncate); //Pre-0.7.0: no ConvolutionMode. Want to default to truncate here if not set + assertEquals(ConvolutionMode.Truncate, l1.getConvolutionMode()); //Pre-0.7.0: no ConvolutionMode. Want to default to truncate here if not set OutputLayer l2 = (OutputLayer) conf.getConf(2).getLayer(); assertEquals("sigmoid", l2.getActivationFn().toString()); diff --git a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/regressiontest/RegressionTest060.java b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/regressiontest/RegressionTest060.java index 4e28c8bdf..d6d404d7d 100644 --- a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/regressiontest/RegressionTest060.java +++ b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/regressiontest/RegressionTest060.java @@ -162,14 +162,14 @@ public class RegressionTest060 extends BaseDL4JTest { assertArrayEquals(new int[] {2, 2}, l0.getKernelSize()); assertArrayEquals(new int[] {1, 1}, l0.getStride()); assertArrayEquals(new int[] {0, 0}, l0.getPadding()); - assertEquals(l0.getConvolutionMode(), ConvolutionMode.Truncate); //Pre-0.7.0: no ConvolutionMode. Want to default to truncate here if not set + assertEquals(ConvolutionMode.Truncate, l0.getConvolutionMode()); //Pre-0.7.0: no ConvolutionMode. Want to default to truncate here if not set SubsamplingLayer l1 = (SubsamplingLayer) conf.getConf(1).getLayer(); assertArrayEquals(new int[] {2, 2}, l1.getKernelSize()); assertArrayEquals(new int[] {1, 1}, l1.getStride()); assertArrayEquals(new int[] {0, 0}, l1.getPadding()); assertEquals(PoolingType.MAX, l1.getPoolingType()); - assertEquals(l1.getConvolutionMode(), ConvolutionMode.Truncate); //Pre-0.7.0: no ConvolutionMode. Want to default to truncate here if not set + assertEquals(ConvolutionMode.Truncate, l1.getConvolutionMode()); //Pre-0.7.0: no ConvolutionMode. Want to default to truncate here if not set OutputLayer l2 = (OutputLayer) conf.getConf(2).getLayer(); assertEquals("sigmoid", l2.getActivationFn().toString()); diff --git a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/regressiontest/RegressionTest071.java b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/regressiontest/RegressionTest071.java index 1b59c0616..2c157b046 100644 --- a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/regressiontest/RegressionTest071.java +++ b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/regressiontest/RegressionTest071.java @@ -162,7 +162,7 @@ public class RegressionTest071 extends BaseDL4JTest { assertArrayEquals(new int[] {2, 2}, l0.getKernelSize()); assertArrayEquals(new int[] {1, 1}, l0.getStride()); assertArrayEquals(new int[] {0, 0}, l0.getPadding()); - assertEquals(l0.getConvolutionMode(), ConvolutionMode.Same); + assertEquals(ConvolutionMode.Same, l0.getConvolutionMode()); SubsamplingLayer l1 = (SubsamplingLayer) conf.getConf(1).getLayer(); assertArrayEquals(new int[] {2, 2}, l1.getKernelSize()); diff --git a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/regressiontest/RegressionTest080.java b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/regressiontest/RegressionTest080.java index 7eb746c4b..9a8dd5ee0 100644 --- a/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/regressiontest/RegressionTest080.java +++ b/deeplearning4j/deeplearning4j-core/src/test/java/org/deeplearning4j/regressiontest/RegressionTest080.java @@ -176,14 +176,14 @@ public class RegressionTest080 extends BaseDL4JTest { assertArrayEquals(new int[] {2, 2}, l0.getKernelSize()); assertArrayEquals(new int[] {1, 1}, l0.getStride()); assertArrayEquals(new int[] {0, 0}, l0.getPadding()); - assertEquals(l0.getConvolutionMode(), ConvolutionMode.Same); + assertEquals(ConvolutionMode.Same, l0.getConvolutionMode()); SubsamplingLayer l1 = (SubsamplingLayer) conf.getConf(1).getLayer(); assertArrayEquals(new int[] {2, 2}, l1.getKernelSize()); assertArrayEquals(new int[] {1, 1}, l1.getStride()); assertArrayEquals(new int[] {0, 0}, l1.getPadding()); assertEquals(PoolingType.MAX, l1.getPoolingType()); - assertEquals(l1.getConvolutionMode(), ConvolutionMode.Same); + assertEquals(ConvolutionMode.Same, l1.getConvolutionMode()); OutputLayer l2 = (OutputLayer) conf.getConf(2).getLayer(); assertTrue(l2.getActivationFn() instanceof ActivationSigmoid); diff --git a/deeplearning4j/deeplearning4j-data/deeplearning4j-datasets/src/main/java/org/deeplearning4j/datasets/fetchers/EmnistDataFetcher.java b/deeplearning4j/deeplearning4j-data/deeplearning4j-datasets/src/main/java/org/deeplearning4j/datasets/fetchers/EmnistDataFetcher.java index 674043a8a..071c8c009 100644 --- a/deeplearning4j/deeplearning4j-data/deeplearning4j-datasets/src/main/java/org/deeplearning4j/datasets/fetchers/EmnistDataFetcher.java +++ b/deeplearning4j/deeplearning4j-data/deeplearning4j-datasets/src/main/java/org/deeplearning4j/datasets/fetchers/EmnistDataFetcher.java @@ -16,6 +16,7 @@ package org.deeplearning4j.datasets.fetchers; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.FileUtils; import org.apache.commons.io.FilenameUtils; import org.deeplearning4j.base.EmnistFetcher; @@ -36,6 +37,7 @@ import java.util.Random; * @author Alex Black * */ +@Slf4j public class EmnistDataFetcher extends MnistDataFetcher implements DataSetFetcher { protected EmnistFetcher fetcher; @@ -64,7 +66,7 @@ public class EmnistDataFetcher extends MnistDataFetcher implements DataSetFetche try { man = new MnistManager(images, labels, totalExamples); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); FileUtils.deleteDirectory(new File(EMNIST_ROOT)); new EmnistFetcher(dataSet).downloadAndUntar(); man = new MnistManager(images, labels, totalExamples); diff --git a/deeplearning4j/deeplearning4j-manifold/deeplearning4j-tsne/src/main/java/org/deeplearning4j/plot/BarnesHutTsne.java b/deeplearning4j/deeplearning4j-manifold/deeplearning4j-tsne/src/main/java/org/deeplearning4j/plot/BarnesHutTsne.java index 8b8b6a524..7595a0777 100644 --- a/deeplearning4j/deeplearning4j-manifold/deeplearning4j-tsne/src/main/java/org/deeplearning4j/plot/BarnesHutTsne.java +++ b/deeplearning4j/deeplearning4j-manifold/deeplearning4j-tsne/src/main/java/org/deeplearning4j/plot/BarnesHutTsne.java @@ -687,9 +687,7 @@ public class BarnesHutTsne implements Model { * @throws IOException */ public void saveAsFile(List labels, String path) throws IOException { - BufferedWriter write = null; - try { - write = new BufferedWriter(new FileWriter(new File(path))); + try (BufferedWriter write = new BufferedWriter(new FileWriter(new File(path)))) { for (int i = 0; i < Y.rows(); i++) { if (i >= labels.size()) break; @@ -711,17 +709,11 @@ public class BarnesHutTsne implements Model { } write.flush(); - write.close(); - } finally { - if (write != null) - write.close(); } } public void saveAsFile(String path) throws IOException { - BufferedWriter write = null; - try { - write = new BufferedWriter(new FileWriter(new File(path))); + try (BufferedWriter write = new BufferedWriter(new FileWriter(new File(path)))) { for (int i = 0; i < Y.rows(); i++) { StringBuilder sb = new StringBuilder(); INDArray wordVector = Y.getRow(i); @@ -734,10 +726,6 @@ public class BarnesHutTsne implements Model { write.write(sb.toString()); } write.flush(); - write.close(); - } finally { - if (write != null) - write.close(); } } /** diff --git a/deeplearning4j/deeplearning4j-modelimport/src/main/java/org/deeplearning4j/nn/modelimport/keras/Hdf5Archive.java b/deeplearning4j/deeplearning4j-modelimport/src/main/java/org/deeplearning4j/nn/modelimport/keras/Hdf5Archive.java index a5ea8efca..73a9a26ea 100644 --- a/deeplearning4j/deeplearning4j-modelimport/src/main/java/org/deeplearning4j/nn/modelimport/keras/Hdf5Archive.java +++ b/deeplearning4j/deeplearning4j-modelimport/src/main/java/org/deeplearning4j/nn/modelimport/keras/Hdf5Archive.java @@ -60,7 +60,7 @@ public class Hdf5Archive implements Closeable { /* This is necessary for the call to the BytePointer constructor below. */ Loader.load(org.bytedeco.hdf5.global.hdf5.class); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); } } diff --git a/deeplearning4j/deeplearning4j-modelimport/src/test/java/org/deeplearning4j/nn/modelimport/keras/configurations/KerasModelImportTest.java b/deeplearning4j/deeplearning4j-modelimport/src/test/java/org/deeplearning4j/nn/modelimport/keras/configurations/KerasModelImportTest.java index cf51831a2..5a10760d5 100644 --- a/deeplearning4j/deeplearning4j-modelimport/src/test/java/org/deeplearning4j/nn/modelimport/keras/configurations/KerasModelImportTest.java +++ b/deeplearning4j/deeplearning4j-modelimport/src/test/java/org/deeplearning4j/nn/modelimport/keras/configurations/KerasModelImportTest.java @@ -69,7 +69,7 @@ public class KerasModelImportTest extends BaseDL4JTest { network = KerasModelImport.importKerasSequentialModelAndWeights(Resources.asFile(modelJsonFilename).getAbsolutePath(), Resources.asFile(modelWeightFilename).getAbsolutePath(), false); } catch (IOException | InvalidKerasConfigurationException | UnsupportedKerasConfigurationException e) { - e.printStackTrace(); + log.error("",e); } return network; @@ -80,7 +80,7 @@ public class KerasModelImportTest extends BaseDL4JTest { try { model = KerasModelImport.importKerasSequentialModelAndWeights(Resources.asFile(modelFilename).getAbsolutePath()); } catch (IOException | InvalidKerasConfigurationException | UnsupportedKerasConfigurationException e) { - e.printStackTrace(); + log.error("",e); } return model; diff --git a/deeplearning4j/deeplearning4j-nearestneighbors-parent/deeplearning4j-nearestneighbor-server/src/main/java/org/deeplearning4j/nearestneighbor/server/NearestNeighborsServer.java b/deeplearning4j/deeplearning4j-nearestneighbors-parent/deeplearning4j-nearestneighbor-server/src/main/java/org/deeplearning4j/nearestneighbor/server/NearestNeighborsServer.java index 6610e75f9..33c651dee 100644 --- a/deeplearning4j/deeplearning4j-nearestneighbors-parent/deeplearning4j-nearestneighbor-server/src/main/java/org/deeplearning4j/nearestneighbor/server/NearestNeighborsServer.java +++ b/deeplearning4j/deeplearning4j-nearestneighbors-parent/deeplearning4j-nearestneighbor-server/src/main/java/org/deeplearning4j/nearestneighbor/server/NearestNeighborsServer.java @@ -210,7 +210,6 @@ public class NearestNeighborsServer extends AbstractVerticle { return; } catch (Throwable e) { log.error("Error in POST /knn",e); - e.printStackTrace(); rc.response().setStatusCode(HttpResponseStatus.INTERNAL_SERVER_ERROR.code()) .end("Error parsing request - " + e.getMessage()); return; @@ -265,7 +264,6 @@ public class NearestNeighborsServer extends AbstractVerticle { .end(j); } catch (Throwable e) { log.error("Error in POST /knnnew",e); - e.printStackTrace(); rc.response().setStatusCode(HttpResponseStatus.INTERNAL_SERVER_ERROR.code()) .end("Error parsing request - " + e.getMessage()); return; diff --git a/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp-chinese/src/main/java/org/ansj/recognition/impl/StopRecognition.java b/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp-chinese/src/main/java/org/ansj/recognition/impl/StopRecognition.java index bbdd2597e..4449155af 100644 --- a/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp-chinese/src/main/java/org/ansj/recognition/impl/StopRecognition.java +++ b/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp-chinese/src/main/java/org/ansj/recognition/impl/StopRecognition.java @@ -75,7 +75,6 @@ public class StopRecognition implements Recognition { try { regexList.add(Pattern.compile(regex)); } catch (Exception e) { - e.printStackTrace(); LOG.error("regex err : " + regex, e); } } diff --git a/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp-japanese/src/main/java/com/atilika/kuromoji/compile/DictionaryCompilerBase.java b/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp-japanese/src/main/java/com/atilika/kuromoji/compile/DictionaryCompilerBase.java index b090c7d07..e5f1c3379 100644 --- a/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp-japanese/src/main/java/com/atilika/kuromoji/compile/DictionaryCompilerBase.java +++ b/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp-japanese/src/main/java/com/atilika/kuromoji/compile/DictionaryCompilerBase.java @@ -20,10 +20,12 @@ import com.atilika.kuromoji.dict.CharacterDefinitions; import com.atilika.kuromoji.dict.ConnectionCosts; import com.atilika.kuromoji.dict.UnknownDictionary; import com.atilika.kuromoji.trie.DoubleArrayTrie; +import lombok.extern.slf4j.Slf4j; import java.io.*; import java.util.List; +@Slf4j public abstract class DictionaryCompilerBase { public void build(String inputDirname, String outputDirname, String encoding, boolean compactTries) @@ -66,7 +68,7 @@ public abstract class DictionaryCompilerBase { } } } catch (Exception e) { - e.printStackTrace(); + log.error("",e); } ProgressLog.end(); diff --git a/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp-japanese/src/main/java/com/atilika/kuromoji/util/FileResourceResolver.java b/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp-japanese/src/main/java/com/atilika/kuromoji/util/FileResourceResolver.java index 8338f42a0..2e6377ec5 100644 --- a/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp-japanese/src/main/java/com/atilika/kuromoji/util/FileResourceResolver.java +++ b/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp-japanese/src/main/java/com/atilika/kuromoji/util/FileResourceResolver.java @@ -33,7 +33,6 @@ public class FileResourceResolver implements ResourceResolver { try { KuromojiBinFilesFetcher.downloadAndUntar(); } catch (IOException e) { - e.printStackTrace(); log.error("IOException : ", e); } } diff --git a/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp-uima/src/main/java/org/deeplearning4j/text/corpora/sentiwordnet/SWN3.java b/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp-uima/src/main/java/org/deeplearning4j/text/corpora/sentiwordnet/SWN3.java index 03d2462a5..f82838ea5 100755 --- a/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp-uima/src/main/java/org/deeplearning4j/text/corpora/sentiwordnet/SWN3.java +++ b/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp-uima/src/main/java/org/deeplearning4j/text/corpora/sentiwordnet/SWN3.java @@ -16,6 +16,7 @@ package org.deeplearning4j.text.corpora.sentiwordnet; +import lombok.extern.slf4j.Slf4j; import org.nd4j.shade.guava.collect.Sets; import org.apache.uima.analysis_engine.AnalysisEngine; import org.apache.uima.cas.CAS; @@ -37,6 +38,7 @@ import java.util.*; * @author Adam Gibson * */ +@Slf4j public class SWN3 implements Serializable { /** * @@ -120,7 +122,7 @@ public class SWN3 implements Serializable { try { csv.close(); } catch (IOException e) { - e.printStackTrace(); + log.error("",e); } } } diff --git a/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp-uima/src/main/java/org/deeplearning4j/text/tokenization/tokenizer/UimaTokenizer.java b/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp-uima/src/main/java/org/deeplearning4j/text/tokenization/tokenizer/UimaTokenizer.java index 830165ec0..b1068e0ab 100755 --- a/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp-uima/src/main/java/org/deeplearning4j/text/tokenization/tokenizer/UimaTokenizer.java +++ b/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp-uima/src/main/java/org/deeplearning4j/text/tokenization/tokenizer/UimaTokenizer.java @@ -16,6 +16,7 @@ package org.deeplearning4j.text.tokenization.tokenizer; +import lombok.extern.slf4j.Slf4j; import org.apache.uima.cas.CAS; import org.apache.uima.fit.util.JCasUtil; import org.cleartk.token.type.Token; @@ -32,6 +33,7 @@ import java.util.List; * @author Adam Gibson * */ +@Slf4j public class UimaTokenizer implements Tokenizer { private List tokens; @@ -66,7 +68,7 @@ public class UimaTokenizer implements Tokenizer { } catch (Exception e) { - e.printStackTrace(); + log.error("",e); throw new RuntimeException(e); } diff --git a/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp-uima/src/test/java/org/deeplearning4j/models/word2vec/Word2VecTests.java b/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp-uima/src/test/java/org/deeplearning4j/models/word2vec/Word2VecTests.java index 7dcfb160a..f205a0994 100755 --- a/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp-uima/src/test/java/org/deeplearning4j/models/word2vec/Word2VecTests.java +++ b/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp-uima/src/test/java/org/deeplearning4j/models/word2vec/Word2VecTests.java @@ -16,6 +16,7 @@ package org.deeplearning4j.models.word2vec; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.IOUtils; import org.apache.commons.io.LineIterator; import org.deeplearning4j.text.sentenceiterator.CollectionSentenceIterator; @@ -64,6 +65,7 @@ import static org.junit.Assert.*; /** * @author jeffreytang */ +@Slf4j public class Word2VecTests extends BaseDL4JTest { private static final Logger log = LoggerFactory.getLogger(Word2VecTests.class); @@ -621,7 +623,7 @@ public class Word2VecTests extends BaseDL4JTest { unserialized = Word2Vec.fromJson(json); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); fail(); } diff --git a/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/models/sequencevectors/listeners/SerializingListener.java b/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/models/sequencevectors/listeners/SerializingListener.java index 8d49720e3..2afbde2b7 100644 --- a/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/models/sequencevectors/listeners/SerializingListener.java +++ b/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/models/sequencevectors/listeners/SerializingListener.java @@ -17,6 +17,7 @@ package org.deeplearning4j.models.sequencevectors.listeners; import lombok.NonNull; +import lombok.extern.slf4j.Slf4j; import org.deeplearning4j.models.sequencevectors.SequenceVectors; import org.deeplearning4j.models.sequencevectors.enums.ListenerEvent; import org.deeplearning4j.models.sequencevectors.interfaces.VectorsListener; @@ -34,6 +35,7 @@ import java.util.concurrent.Semaphore; * * @author raver119@gmail.com */ +@Slf4j public class SerializingListener implements VectorsListener { private File targetFolder = new File("./"); private String modelPrefix = "Model_"; @@ -96,7 +98,7 @@ public class SerializingListener implements VectorsLi } } catch (Exception e) { - e.printStackTrace(); + log.error("",e); } finally { locker.release(); } diff --git a/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/models/sequencevectors/transformers/impl/iterables/ParallelTransformerIterator.java b/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/models/sequencevectors/transformers/impl/iterables/ParallelTransformerIterator.java index ac974d811..01c0bb9e7 100644 --- a/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/models/sequencevectors/transformers/impl/iterables/ParallelTransformerIterator.java +++ b/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/models/sequencevectors/transformers/impl/iterables/ParallelTransformerIterator.java @@ -147,7 +147,7 @@ public class ParallelTransformerIterator extends BasicTransformerIterator { try { buffer.put(futureSequence); } catch (InterruptedException e) { - e.printStackTrace(); + log.error("",e); } } /* else diff --git a/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/text/documentiterator/AsyncLabelAwareIterator.java b/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/text/documentiterator/AsyncLabelAwareIterator.java index cf9337b5b..dd87f9b1f 100644 --- a/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/text/documentiterator/AsyncLabelAwareIterator.java +++ b/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/text/documentiterator/AsyncLabelAwareIterator.java @@ -21,6 +21,7 @@ import lombok.NonNull; import org.deeplearning4j.parallelism.AsyncIterator; import java.util.Iterator; +import java.util.NoSuchElementException; /** * @author raver119@gmail.com @@ -77,7 +78,7 @@ public class AsyncLabelAwareIterator implements LabelAwareIterator, Iterator { private BufferedReader reader; @@ -113,7 +115,7 @@ public class BasicLineIterator implements SentenceIterator, Iterable { reader.close(); } catch (Exception e) { // do nothing here - e.printStackTrace(); + log.error("",e); } super.finalize(); } diff --git a/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/text/sentenceiterator/StreamLineIterator.java b/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/text/sentenceiterator/StreamLineIterator.java index 737e43b26..156e88958 100644 --- a/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/text/sentenceiterator/StreamLineIterator.java +++ b/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/text/sentenceiterator/StreamLineIterator.java @@ -17,6 +17,7 @@ package org.deeplearning4j.text.sentenceiterator; import lombok.NonNull; +import lombok.extern.slf4j.Slf4j; import org.deeplearning4j.text.documentiterator.DocumentIterator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -35,6 +36,7 @@ import java.util.concurrent.atomic.AtomicBoolean; * * @author raver119@gmail.com */ +@Slf4j public class StreamLineIterator implements SentenceIterator { private DocumentIterator iterator; private int linesToFetch; @@ -64,7 +66,7 @@ public class StreamLineIterator implements SentenceIterator { currentReader = null; } } catch (IOException e) { - e.printStackTrace(); + log.error("",e); throw new RuntimeException(e); } } @@ -145,7 +147,7 @@ public class StreamLineIterator implements SentenceIterator { try { this.onlyStream.reset(); } catch (IOException e) { - e.printStackTrace(); + log.error("",e); throw new RuntimeException(e); } } diff --git a/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/test/java/org/deeplearning4j/models/fasttext/FastTextTest.java b/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/test/java/org/deeplearning4j/models/fasttext/FastTextTest.java index eba2bce85..2e3ec06c2 100644 --- a/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/test/java/org/deeplearning4j/models/fasttext/FastTextTest.java +++ b/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/test/java/org/deeplearning4j/models/fasttext/FastTextTest.java @@ -183,7 +183,7 @@ public class FastTextTest extends BaseDL4JTest { fastText.loadIterator(); } catch (IOException e) { - log.error(e.toString()); + log.error("",e); } } diff --git a/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/test/java/org/deeplearning4j/models/paragraphvectors/ParagraphVectorsTest.java b/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/test/java/org/deeplearning4j/models/paragraphvectors/ParagraphVectorsTest.java index 14495ffaf..a7423984c 100644 --- a/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/test/java/org/deeplearning4j/models/paragraphvectors/ParagraphVectorsTest.java +++ b/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/test/java/org/deeplearning4j/models/paragraphvectors/ParagraphVectorsTest.java @@ -1164,7 +1164,7 @@ public class ParagraphVectorsTest extends BaseDL4JTest { unserialized = ParagraphVectors.fromJson(json); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); fail(); } diff --git a/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/test/java/org/deeplearning4j/models/sequencevectors/serialization/WordVectorSerializerTest.java b/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/test/java/org/deeplearning4j/models/sequencevectors/serialization/WordVectorSerializerTest.java index 4e70cb212..b7aff923e 100644 --- a/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/test/java/org/deeplearning4j/models/sequencevectors/serialization/WordVectorSerializerTest.java +++ b/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/test/java/org/deeplearning4j/models/sequencevectors/serialization/WordVectorSerializerTest.java @@ -16,6 +16,7 @@ package org.deeplearning4j.models.sequencevectors.serialization; +import lombok.extern.slf4j.Slf4j; import lombok.val; import org.apache.commons.lang.StringUtils; import org.deeplearning4j.BaseDL4JTest; @@ -48,6 +49,7 @@ import java.util.Collections; import static org.junit.Assert.*; +@Slf4j public class WordVectorSerializerTest extends BaseDL4JTest { private AbstractCache cache; @@ -97,7 +99,7 @@ public class WordVectorSerializerTest extends BaseDL4JTest { byte[] bytesResult = baos.toByteArray(); deser = WordVectorSerializer.readSequenceVectors(new ByteArrayInputStream(bytesResult), true); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); fail(); } @@ -175,7 +177,7 @@ public class WordVectorSerializerTest extends BaseDL4JTest { byte[] bytesResult = baos.toByteArray(); deser = WordVectorSerializer.readWord2Vec(new ByteArrayInputStream(bytesResult), true); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); fail(); } @@ -223,7 +225,7 @@ public class WordVectorSerializerTest extends BaseDL4JTest { byte[] bytesResult = baos.toByteArray(); deser = WordVectorSerializer.readWord2Vec(new ByteArrayInputStream(bytesResult), true); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); fail(); } @@ -268,7 +270,7 @@ public class WordVectorSerializerTest extends BaseDL4JTest { ByteArrayOutputStream baos = new ByteArrayOutputStream(); deser = WordVectorSerializer.readLookupTable(file); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); fail(); } assertEquals(lookupTable.getVocab().totalWordOccurrences(), ((InMemoryLookupTable)deser).getVocab().totalWordOccurrences()); @@ -306,7 +308,7 @@ public class WordVectorSerializerTest extends BaseDL4JTest { ByteArrayOutputStream baos = new ByteArrayOutputStream(); deser = WordVectorSerializer.readWordVectors(new File(dir, "some.data")); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); fail(); } diff --git a/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/test/java/org/deeplearning4j/models/word2vec/wordstore/inmemory/AbstractCacheTest.java b/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/test/java/org/deeplearning4j/models/word2vec/wordstore/inmemory/AbstractCacheTest.java index 8e434644f..c2770486d 100644 --- a/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/test/java/org/deeplearning4j/models/word2vec/wordstore/inmemory/AbstractCacheTest.java +++ b/deeplearning4j/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/test/java/org/deeplearning4j/models/word2vec/wordstore/inmemory/AbstractCacheTest.java @@ -140,7 +140,7 @@ public class AbstractCacheTest extends BaseDL4JTest { unserialized = AbstractCache.fromJson(json); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); fail(); } assertEquals(cache.totalWordOccurrences(),unserialized.totalWordOccurrences()); @@ -175,7 +175,7 @@ public class AbstractCacheTest extends BaseDL4JTest { unserialized = AbstractCache.fromJson(json); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); fail(); } assertEquals(cache.totalWordOccurrences(),unserialized.totalWordOccurrences()); diff --git a/deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/nn/layers/AbstractLayer.java b/deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/nn/layers/AbstractLayer.java index ad8590b0b..ebf8d7092 100644 --- a/deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/nn/layers/AbstractLayer.java +++ b/deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/nn/layers/AbstractLayer.java @@ -63,7 +63,7 @@ public abstract class AbstractLayer extends AbstractLayer { @@ -371,7 +373,7 @@ public abstract class BaseLayer> { private String tokenizerFactoryClazz; private String tokenizerPreprocessorClazz; @@ -69,7 +71,7 @@ public class TokenizerFunction implements Function> { tokenizerFactory = new NGramTokenizerFactory(tokenizerFactory, nGrams, nGrams); } } catch (Exception e) { - e.printStackTrace(); + log.error("",e); } return tokenizerFactory; } diff --git a/deeplearning4j/deeplearning4j-scaleout/spark/dl4j-spark-parameterserver/src/main/java/org/deeplearning4j/spark/parameterserver/networking/v2/UpdatesConsumer.java b/deeplearning4j/deeplearning4j-scaleout/spark/dl4j-spark-parameterserver/src/main/java/org/deeplearning4j/spark/parameterserver/networking/v2/UpdatesConsumer.java index 2cf251cda..d3a406ea8 100644 --- a/deeplearning4j/deeplearning4j-scaleout/spark/dl4j-spark-parameterserver/src/main/java/org/deeplearning4j/spark/parameterserver/networking/v2/UpdatesConsumer.java +++ b/deeplearning4j/deeplearning4j-scaleout/spark/dl4j-spark-parameterserver/src/main/java/org/deeplearning4j/spark/parameterserver/networking/v2/UpdatesConsumer.java @@ -120,7 +120,7 @@ public class UpdatesConsumer implements UpdatesHandler { //log.info("Putting update to the queue, current size: [{}]", updatesBuffer.size()); updatesBuffer.put(array); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); throw new RuntimeException(e); } } else if (params != null && stepFunction != null) { diff --git a/deeplearning4j/deeplearning4j-scaleout/spark/dl4j-spark/src/main/java/org/deeplearning4j/spark/datavec/DataVecByteDataSetFunction.java b/deeplearning4j/deeplearning4j-scaleout/spark/dl4j-spark/src/main/java/org/deeplearning4j/spark/datavec/DataVecByteDataSetFunction.java index 9058dd5af..9627c82bd 100644 --- a/deeplearning4j/deeplearning4j-scaleout/spark/dl4j-spark/src/main/java/org/deeplearning4j/spark/datavec/DataVecByteDataSetFunction.java +++ b/deeplearning4j/deeplearning4j-scaleout/spark/dl4j-spark/src/main/java/org/deeplearning4j/spark/datavec/DataVecByteDataSetFunction.java @@ -16,6 +16,7 @@ package org.deeplearning4j.spark.datavec; +import lombok.extern.slf4j.Slf4j; import org.apache.hadoop.io.BytesWritable; import org.apache.hadoop.io.Text; import org.apache.spark.api.java.function.PairFunction; @@ -35,6 +36,7 @@ import java.util.List; /** */ +@Slf4j public class DataVecByteDataSetFunction implements PairFunction, Double, DataSet> { private int labelIndex = 0; @@ -104,7 +106,7 @@ public class DataVecByteDataSetFunction implements PairFunction inputs = new ArrayList<>(); diff --git a/deeplearning4j/deeplearning4j-scaleout/spark/dl4j-spark/src/main/java/org/deeplearning4j/spark/datavec/DataVecDataSetFunction.java b/deeplearning4j/deeplearning4j-scaleout/spark/dl4j-spark/src/main/java/org/deeplearning4j/spark/datavec/DataVecDataSetFunction.java index 3f111911c..801d2b420 100644 --- a/deeplearning4j/deeplearning4j-scaleout/spark/dl4j-spark/src/main/java/org/deeplearning4j/spark/datavec/DataVecDataSetFunction.java +++ b/deeplearning4j/deeplearning4j-scaleout/spark/dl4j-spark/src/main/java/org/deeplearning4j/spark/datavec/DataVecDataSetFunction.java @@ -16,6 +16,7 @@ package org.deeplearning4j.spark.datavec; +import lombok.extern.slf4j.Slf4j; import org.apache.spark.api.java.function.Function; import org.datavec.api.io.WritableConverter; import org.datavec.api.io.converters.WritableConverterException; @@ -36,6 +37,7 @@ import java.util.List; * Analogous to {@link RecordReaderDataSetIterator}, but in the context of Spark. * @author Alex Black */ +@Slf4j public class DataVecDataSetFunction implements Function, DataSet>, Serializable { private final int labelIndex; @@ -129,7 +131,8 @@ public class DataVecDataSetFunction implements Function, DataSet> try { current = converter.convert(current); } catch (WritableConverterException e) { - e.printStackTrace(); + + log.error("",e); } } if (regression) { diff --git a/deeplearning4j/deeplearning4j-scaleout/spark/dl4j-spark/src/test/java/org/deeplearning4j/spark/impl/common/repartition/BalancedPartitionerTest.java b/deeplearning4j/deeplearning4j-scaleout/spark/dl4j-spark/src/test/java/org/deeplearning4j/spark/impl/common/repartition/BalancedPartitionerTest.java index c93952a4e..b3be0029c 100644 --- a/deeplearning4j/deeplearning4j-scaleout/spark/dl4j-spark/src/test/java/org/deeplearning4j/spark/impl/common/repartition/BalancedPartitionerTest.java +++ b/deeplearning4j/deeplearning4j-scaleout/spark/dl4j-spark/src/test/java/org/deeplearning4j/spark/impl/common/repartition/BalancedPartitionerTest.java @@ -33,7 +33,7 @@ public class BalancedPartitionerTest { // the 10 first elements should go in the 1st partition for (int i = 0; i < 10; i++) { int p = bp.getPartition(i); - assertEquals("Found wrong partition output " + p + ", not 0", p, 0); + assertEquals("Found wrong partition output " + p + ", not 0", 0, p); } } @@ -43,7 +43,7 @@ public class BalancedPartitionerTest { // the 10 first elements should go in the 1st partition for (int i = 0; i < 10; i++) { int p = bp.getPartition(i); - assertEquals("Found wrong partition output " + p + ", not 0", p, 0); + assertEquals("Found wrong partition output " + p + ", not 0", 0, p); } } @@ -56,7 +56,7 @@ public class BalancedPartitionerTest { countPerPartition[p] += 1; } for (int i = 0; i < 10; i++) { - assertEquals(countPerPartition[i], 10); + assertEquals(10, countPerPartition[i]); } } @@ -70,9 +70,9 @@ public class BalancedPartitionerTest { } for (int i = 0; i < 10; i++) { if (i < 7) - assertEquals(countPerPartition[i], 10 + 1); + assertEquals(10 + 1, countPerPartition[i]); else - assertEquals(countPerPartition[i], 10); + assertEquals(10, countPerPartition[i]); } } diff --git a/deeplearning4j/deeplearning4j-ui-parent/deeplearning4j-ui-model/src/main/java/org/deeplearning4j/ui/stats/BaseStatsListener.java b/deeplearning4j/deeplearning4j-ui-parent/deeplearning4j-ui-model/src/main/java/org/deeplearning4j/ui/stats/BaseStatsListener.java index 233633ab9..979f811e5 100644 --- a/deeplearning4j/deeplearning4j-ui-parent/deeplearning4j-ui-model/src/main/java/org/deeplearning4j/ui/stats/BaseStatsListener.java +++ b/deeplearning4j/deeplearning4j-ui-parent/deeplearning4j-ui-model/src/main/java/org/deeplearning4j/ui/stats/BaseStatsListener.java @@ -385,7 +385,7 @@ public abstract class BaseStatsListener implements RoutingIterationListener { gpuMaxBytes[i] = nativeOps.getDeviceTotalMemory(0); gpuCurrentBytes[i] = gpuMaxBytes[i] - nativeOps.getDeviceFreeMemory(0); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); } } } diff --git a/deeplearning4j/deeplearning4j-ui-parent/deeplearning4j-ui/src/main/java/org/deeplearning4j/ui/weights/ConvolutionalIterationListener.java b/deeplearning4j/deeplearning4j-ui-parent/deeplearning4j-ui/src/main/java/org/deeplearning4j/ui/weights/ConvolutionalIterationListener.java index 4aae630ca..1c12af527 100644 --- a/deeplearning4j/deeplearning4j-ui-parent/deeplearning4j-ui/src/main/java/org/deeplearning4j/ui/weights/ConvolutionalIterationListener.java +++ b/deeplearning4j/deeplearning4j-ui-parent/deeplearning4j-ui/src/main/java/org/deeplearning4j/ui/weights/ConvolutionalIterationListener.java @@ -17,6 +17,7 @@ package org.deeplearning4j.ui.weights; import lombok.NonNull; +import lombok.extern.slf4j.Slf4j; import lombok.val; import org.datavec.image.loader.ImageLoader; import org.deeplearning4j.api.storage.Persistable; @@ -49,6 +50,7 @@ import java.util.List; /** * @author raver119@gmail.com */ +@Slf4j public class ConvolutionalIterationListener extends BaseTrainingListener { private enum Orientation { @@ -661,7 +663,7 @@ public class ConvolutionalIterationListener extends BaseTrainingListener { try { ImageIO.write(renderImageGrayscale(array), "png", file); } catch (IOException e) { - e.printStackTrace(); + log.error("",e); } } @@ -670,7 +672,7 @@ public class ConvolutionalIterationListener extends BaseTrainingListener { try { ImageIO.write(image, "png", file); } catch (IOException e) { - e.printStackTrace(); + log.error("",e); } } diff --git a/deeplearning4j/deeplearning4j-ui-parent/deeplearning4j-ui/src/test/java/org/deeplearning4j/ui/ManualTests.java b/deeplearning4j/deeplearning4j-ui-parent/deeplearning4j-ui/src/test/java/org/deeplearning4j/ui/ManualTests.java index 7621faa3b..a489dc854 100644 --- a/deeplearning4j/deeplearning4j-ui-parent/deeplearning4j-ui/src/test/java/org/deeplearning4j/ui/ManualTests.java +++ b/deeplearning4j/deeplearning4j-ui-parent/deeplearning4j-ui/src/test/java/org/deeplearning4j/ui/ManualTests.java @@ -16,6 +16,7 @@ package org.deeplearning4j.ui; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.IOUtils; import org.datavec.image.loader.LFWLoader; import org.deeplearning4j.datasets.iterator.impl.LFWDataSetIterator; @@ -82,6 +83,7 @@ import static org.junit.Assert.fail; * @author raver119@gmail.com */ @Ignore +@Slf4j public class ManualTests { private static Logger log = LoggerFactory.getLogger(ManualTests.class); @@ -258,7 +260,7 @@ public class ManualTests { try { ImageIO.write(imageToRender, "png", file); } catch (IOException e) { - e.printStackTrace(); + log.error("",e); } } diff --git a/deeplearning4j/deeplearning4j-ui-parent/deeplearning4j-vertx/src/main/java/org/deeplearning4j/ui/module/train/TrainModule.java b/deeplearning4j/deeplearning4j-ui-parent/deeplearning4j-vertx/src/main/java/org/deeplearning4j/ui/module/train/TrainModule.java index 00e2c9422..a644f0c1d 100644 --- a/deeplearning4j/deeplearning4j-ui-parent/deeplearning4j-vertx/src/main/java/org/deeplearning4j/ui/module/train/TrainModule.java +++ b/deeplearning4j/deeplearning4j-ui-parent/deeplearning4j-vertx/src/main/java/org/deeplearning4j/ui/module/train/TrainModule.java @@ -926,7 +926,7 @@ public class TrainModule implements UIModule { NeuralNetConfiguration.mapper().readValue(config, NeuralNetConfiguration.class); return new Triple<>(null, null, layer); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); } } return null; diff --git a/deeplearning4j/deeplearning4j-ui-parent/deeplearning4j-vertx/src/test/java/org/deeplearning4j/ui/TestVertxUIMultiSession.java b/deeplearning4j/deeplearning4j-ui-parent/deeplearning4j-vertx/src/test/java/org/deeplearning4j/ui/TestVertxUIMultiSession.java index 1eeceb2aa..0ca870107 100644 --- a/deeplearning4j/deeplearning4j-ui-parent/deeplearning4j-vertx/src/test/java/org/deeplearning4j/ui/TestVertxUIMultiSession.java +++ b/deeplearning4j/deeplearning4j-ui-parent/deeplearning4j-vertx/src/test/java/org/deeplearning4j/ui/TestVertxUIMultiSession.java @@ -18,6 +18,7 @@ package org.deeplearning4j.ui; import io.netty.handler.codec.http.HttpResponseStatus; +import lombok.extern.slf4j.Slf4j; import org.deeplearning4j.BaseDL4JTest; import org.deeplearning4j.api.storage.StatsStorage; import org.deeplearning4j.datasets.iterator.impl.IrisDataSetIterator; @@ -53,6 +54,7 @@ import static org.junit.Assert.*; * @author Tamas Fenyvesi */ @Ignore +@Slf4j public class TestVertxUIMultiSession extends BaseDL4JTest { @Before public void setUp() throws Exception { @@ -121,7 +123,7 @@ public class TestVertxUIMultiSession extends BaseDL4JTest { assertEquals(HttpResponseStatus.OK.code(), conn.getResponseCode()); assertTrue(uIServer.isAttached(ss)); } catch (InterruptedException | IOException e) { - e.printStackTrace(); + log.error("",e); fail(e.getMessage()); } finally { uIServer.detach(ss); @@ -294,7 +296,7 @@ public class TestVertxUIMultiSession extends BaseDL4JTest { " after " + autoDetachTimeoutMillis + " ms "); Thread.sleep(autoDetachTimeoutMillis); } catch (InterruptedException e) { - e.printStackTrace(); + log.error("",e); } finally { System.out.println("Auto-detaching StatsStorage (session ID: " + sessionId + ") after " + autoDetachTimeoutMillis + " ms."); diff --git a/deeplearning4j/deeplearning4j-zoo/src/main/java/org/deeplearning4j/zoo/model/AlexNet.java b/deeplearning4j/deeplearning4j-zoo/src/main/java/org/deeplearning4j/zoo/model/AlexNet.java index e6461c121..41ddb7874 100644 --- a/deeplearning4j/deeplearning4j-zoo/src/main/java/org/deeplearning4j/zoo/model/AlexNet.java +++ b/deeplearning4j/deeplearning4j-zoo/src/main/java/org/deeplearning4j/zoo/model/AlexNet.java @@ -21,7 +21,6 @@ import lombok.Builder; import org.deeplearning4j.nn.api.Model; import org.deeplearning4j.nn.api.OptimizationAlgorithm; import org.deeplearning4j.nn.conf.*; -import org.deeplearning4j.nn.conf.distribution.GaussianDistribution; import org.deeplearning4j.nn.conf.distribution.NormalDistribution; import org.deeplearning4j.nn.conf.inputs.InputType; import org.deeplearning4j.nn.conf.layers.*; diff --git a/deeplearning4j/dl4j-integration-tests/src/test/java/org/deeplearning4j/integration/IntegrationTestRunner.java b/deeplearning4j/dl4j-integration-tests/src/test/java/org/deeplearning4j/integration/IntegrationTestRunner.java index de1fb07b3..cd1a36493 100644 --- a/deeplearning4j/dl4j-integration-tests/src/test/java/org/deeplearning4j/integration/IntegrationTestRunner.java +++ b/deeplearning4j/dl4j-integration-tests/src/test/java/org/deeplearning4j/integration/IntegrationTestRunner.java @@ -1045,7 +1045,7 @@ public class IntegrationTestRunner { act[j] = inf.output(in.get(j).getFirst(), inMask); counter.incrementAndGet(); } catch (Exception e){ - e.printStackTrace(); + log.error("",e); failedCount.incrementAndGet(); } } diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/functions/DifferentialFunction.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/functions/DifferentialFunction.java index e21b2d270..d4ecb3bce 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/functions/DifferentialFunction.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/functions/DifferentialFunction.java @@ -189,7 +189,7 @@ public abstract class DifferentialFunction { try { return property.get(this); } catch (IllegalAccessException e) { - e.printStackTrace(); + log.error("",e); } return null; diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/listeners/Loss.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/listeners/Loss.java index e85a93739..c67f8bd45 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/listeners/Loss.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/listeners/Loss.java @@ -80,7 +80,7 @@ public class Loss { public static Loss sum(List losses) { - if (losses.size() == 0) + if (losses.isEmpty()) return new Loss(Collections.emptyList(), new double[0]); double[] lossValues = new double[losses.get(0).losses.length]; diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/listeners/impl/HistoryListener.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/listeners/impl/HistoryListener.java index eb0675da5..b337c0656 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/listeners/impl/HistoryListener.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/listeners/impl/HistoryListener.java @@ -17,10 +17,7 @@ package org.nd4j.autodiff.listeners.impl; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; -import java.util.Set; import lombok.Getter; import lombok.Setter; @@ -34,9 +31,6 @@ import org.nd4j.autodiff.listeners.records.LossCurve; import org.nd4j.autodiff.listeners.Operation; import org.nd4j.autodiff.samediff.SameDiff; import org.nd4j.autodiff.samediff.TrainingConfig; -import org.nd4j.autodiff.samediff.internal.SameDiffOp; -import org.nd4j.linalg.api.ndarray.INDArray; -import org.nd4j.linalg.dataset.api.MultiDataSet; /** * HistoryListener is mainly used internally to collect information such as the loss curve and evaluations, diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/internal/AbstractDependencyTracker.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/internal/AbstractDependencyTracker.java index 776d26794..1faea9c66 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/internal/AbstractDependencyTracker.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/internal/AbstractDependencyTracker.java @@ -154,11 +154,9 @@ public abstract class AbstractDependencyTracker { } } - if (allSatisfied) { - if (!this.allSatisfied.contains(t)) { - this.allSatisfied.add(t); - this.allSatisfiedQueue.add(t); - } + if (allSatisfied && !this.allSatisfied.contains(t)) { + this.allSatisfied.add(t); + this.allSatisfiedQueue.add(t); } } } @@ -278,25 +276,25 @@ public abstract class AbstractDependencyTracker { protected boolean isAllSatisfied(@NonNull T y) { Set set1 = dependencies.get(y); - boolean allSatisfied = true; + boolean retVal = true; if (set1 != null) { for (D d : set1) { - allSatisfied = isSatisfied(d); - if (!allSatisfied) + retVal = isSatisfied(d); + if (!retVal) break; } } - if (allSatisfied) { + if (retVal) { Set> set2 = orDependencies.get(y); if (set2 != null) { for (Pair p : set2) { - allSatisfied = isSatisfied(p.getFirst()) || isSatisfied(p.getSecond()); - if (!allSatisfied) + retVal = isSatisfied(p.getFirst()) || isSatisfied(p.getSecond()); + if (!retVal) break; } } } - return allSatisfied; + return retVal; } diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/custom/MergeLambda.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/custom/MergeLambda.java index 079755055..1a6ced62f 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/custom/MergeLambda.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/evaluation/custom/MergeLambda.java @@ -16,8 +16,6 @@ package org.nd4j.evaluation.custom; -import org.nd4j.shade.guava.collect.Lists; - import java.util.List; /** diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/activations/impl/ActivationMish.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/activations/impl/ActivationMish.java index b789a2925..1d1bba123 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/activations/impl/ActivationMish.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/activations/impl/ActivationMish.java @@ -21,10 +21,8 @@ import lombok.Getter; import lombok.val; import org.nd4j.linalg.activations.BaseActivationFunction; import org.nd4j.linalg.api.ndarray.INDArray; -import org.nd4j.linalg.api.ops.impl.transforms.gradient.SeluBp; import org.nd4j.linalg.api.ops.impl.transforms.strict.Mish; import org.nd4j.linalg.api.ops.impl.transforms.strict.MishDerivative; -import org.nd4j.linalg.api.ops.impl.transforms.strict.SELU; import org.nd4j.linalg.factory.Nd4j; import org.nd4j.linalg.primitives.Pair; diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/custom/LinearSolve.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/custom/LinearSolve.java index 7c835006e..a107d8c10 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/custom/LinearSolve.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/custom/LinearSolve.java @@ -19,7 +19,6 @@ import lombok.NoArgsConstructor; import org.nd4j.autodiff.samediff.SDVariable; import org.nd4j.autodiff.samediff.SameDiff; import org.nd4j.base.Preconditions; -import org.nd4j.imports.graphmapper.tf.TFGraphMapper; import org.nd4j.linalg.api.buffer.DataType; import org.nd4j.linalg.api.ndarray.INDArray; import org.nd4j.linalg.api.ops.DynamicCustomOp; diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/custom/Lstsq.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/custom/Lstsq.java index b7c0e4092..2cd862515 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/custom/Lstsq.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/custom/Lstsq.java @@ -24,7 +24,6 @@ import org.nd4j.linalg.api.buffer.DataType; import org.nd4j.linalg.api.ndarray.INDArray; import org.nd4j.linalg.api.ops.DynamicCustomOp; -import java.util.Arrays; import java.util.Collections; import java.util.List; diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/indexaccum/IAMax.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/indexaccum/IAMax.java index 181321d4f..b2e0d1192 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/indexaccum/IAMax.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/indexaccum/IAMax.java @@ -21,7 +21,6 @@ import org.nd4j.autodiff.samediff.SDVariable; import org.nd4j.autodiff.samediff.SameDiff; import org.nd4j.linalg.api.ndarray.INDArray; import org.nd4j.linalg.api.ops.BaseIndexAccumulation; -import org.nd4j.linalg.factory.Nd4j; import java.util.Collections; import java.util.List; diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/indexaccum/IAMin.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/indexaccum/IAMin.java index 760fca314..f20547c1d 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/indexaccum/IAMin.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/indexaccum/IAMin.java @@ -21,7 +21,6 @@ import org.nd4j.autodiff.samediff.SDVariable; import org.nd4j.autodiff.samediff.SameDiff; import org.nd4j.linalg.api.ndarray.INDArray; import org.nd4j.linalg.api.ops.BaseIndexAccumulation; -import org.nd4j.linalg.factory.Nd4j; import java.util.Collections; import java.util.List; diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/layers/convolution/AvgPooling3D.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/layers/convolution/AvgPooling3D.java index 7c6b5186c..c0ec62610 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/layers/convolution/AvgPooling3D.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/layers/convolution/AvgPooling3D.java @@ -68,7 +68,7 @@ public class AvgPooling3D extends Pooling3D { return config.toProperties(); } - + @Override public String getPoolingPrefix() { return "avg"; } diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/layers/convolution/MaxPoolWithArgmax.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/layers/convolution/MaxPoolWithArgmax.java index 5f5f6747a..8b151d717 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/layers/convolution/MaxPoolWithArgmax.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/layers/convolution/MaxPoolWithArgmax.java @@ -82,7 +82,7 @@ public class MaxPoolWithArgmax extends DynamicCustomOp { @Override public Map propertiesForFunction() { - if(config == null && iArguments.size() > 0){ + if(config == null && !iArguments.isEmpty()){ //Perhaps loaded from FlatBuffers - hence we have IArgs but not Config object config = Pooling2DConfig.builder() .kH(iArguments.get(0)) diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/layers/convolution/MaxPooling2D.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/layers/convolution/MaxPooling2D.java index c54b63aa7..1da1f36bf 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/layers/convolution/MaxPooling2D.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/layers/convolution/MaxPooling2D.java @@ -85,7 +85,7 @@ public class MaxPooling2D extends DynamicCustomOp { @Override public Map propertiesForFunction() { - if(config == null && iArguments.size() > 0){ + if(config == null && !iArguments.isEmpty()){ //Perhaps loaded from FlatBuffers - hence we have IArgs but not Config object config = Pooling2DConfig.builder() .kH(iArguments.get(0)) diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/layers/convolution/MaxPooling3D.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/layers/convolution/MaxPooling3D.java index 6c7aec888..e931d1583 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/layers/convolution/MaxPooling3D.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/layers/convolution/MaxPooling3D.java @@ -75,7 +75,7 @@ public class MaxPooling3D extends Pooling3D { return config.toProperties(); } - + @Override public String getPoolingPrefix() { return "max"; } diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/layers/convolution/config/BaseConvolutionConfig.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/layers/convolution/config/BaseConvolutionConfig.java index 1fcd49162..71ef8ffcf 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/layers/convolution/config/BaseConvolutionConfig.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/layers/convolution/config/BaseConvolutionConfig.java @@ -18,11 +18,14 @@ package org.nd4j.linalg.api.ops.impl.layers.convolution.config; import java.util.LinkedHashMap; import java.util.Map; + +import lombok.extern.slf4j.Slf4j; import lombok.val; import org.nd4j.linalg.exception.ND4JIllegalStateException; import java.lang.reflect.Field; +@Slf4j public abstract class BaseConvolutionConfig { public abstract Map toProperties(); @@ -61,7 +64,7 @@ public abstract class BaseConvolutionConfig { try { target.set(this, value); } catch (IllegalAccessException e) { - e.printStackTrace(); + log.error("",e); } } diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/layers/recurrent/LSTMLayer.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/layers/recurrent/LSTMLayer.java index bebbd5f8f..b4567cb0d 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/layers/recurrent/LSTMLayer.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/layers/recurrent/LSTMLayer.java @@ -24,12 +24,10 @@ import org.nd4j.base.Preconditions; import org.nd4j.linalg.api.buffer.DataType; import org.nd4j.linalg.api.ndarray.INDArray; import org.nd4j.linalg.api.ops.DynamicCustomOp; -import org.nd4j.linalg.api.ops.impl.layers.convolution.DepthwiseConv2DBp; import org.nd4j.linalg.api.ops.impl.layers.recurrent.config.LSTMLayerConfig; import org.nd4j.linalg.api.ops.impl.layers.recurrent.weights.LSTMLayerWeights; import org.nd4j.shade.guava.primitives.Booleans; -import javax.xml.crypto.Data; import java.util.ArrayList; import java.util.Arrays; import java.util.List; diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/layers/recurrent/config/LSTMLayerConfig.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/layers/recurrent/config/LSTMLayerConfig.java index 226150e8b..071b6adf3 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/layers/recurrent/config/LSTMLayerConfig.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/layers/recurrent/config/LSTMLayerConfig.java @@ -19,8 +19,6 @@ import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; -import org.nd4j.linalg.api.ops.impl.layers.recurrent.LSTMBlockCell; -import org.nd4j.linalg.api.ops.impl.layers.recurrent.LSTMLayer; import java.util.LinkedHashMap; import java.util.Map; diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/layers/recurrent/outputs/LSTMLayerOutputs.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/layers/recurrent/outputs/LSTMLayerOutputs.java index d8a2e6e9a..7e2b4fb5a 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/layers/recurrent/outputs/LSTMLayerOutputs.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/layers/recurrent/outputs/LSTMLayerOutputs.java @@ -1,19 +1,12 @@ package org.nd4j.linalg.api.ops.impl.layers.recurrent.outputs; -import java.util.Arrays; -import java.util.List; - -import lombok.AccessLevel; import lombok.Getter; -import org.nd4j.autodiff.samediff.SDIndex; import org.nd4j.autodiff.samediff.SDVariable; import org.nd4j.base.Preconditions; import org.nd4j.linalg.api.ops.impl.layers.recurrent.LSTMLayer; import org.nd4j.linalg.api.ops.impl.layers.recurrent.config.LSTMDataFormat; import org.nd4j.linalg.api.ops.impl.layers.recurrent.config.LSTMDirectionMode; import org.nd4j.linalg.api.ops.impl.layers.recurrent.config.LSTMLayerConfig; -import org.nd4j.linalg.api.ops.impl.layers.recurrent.config.RnnDataFormat; -import org.nd4j.shade.guava.primitives.Booleans; /** * The outputs of a LSTM layer ({@link LSTMLayer}. diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/layers/recurrent/weights/LSTMLayerWeights.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/layers/recurrent/weights/LSTMLayerWeights.java index 98985df57..8f0113685 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/layers/recurrent/weights/LSTMLayerWeights.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/layers/recurrent/weights/LSTMLayerWeights.java @@ -22,7 +22,6 @@ import lombok.EqualsAndHashCode; import org.nd4j.autodiff.samediff.SDVariable; import org.nd4j.base.Preconditions; import org.nd4j.linalg.api.ndarray.INDArray; -import org.nd4j.linalg.api.ops.impl.layers.recurrent.LSTMBlockCell; import org.nd4j.linalg.api.ops.impl.layers.recurrent.LSTMLayer; import org.nd4j.linalg.util.ArrayUtil; diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/loss/AbsoluteDifferenceLoss.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/loss/AbsoluteDifferenceLoss.java index 4f6539eee..6146630a3 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/loss/AbsoluteDifferenceLoss.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/loss/AbsoluteDifferenceLoss.java @@ -19,8 +19,6 @@ package org.nd4j.linalg.api.ops.impl.loss; import org.nd4j.autodiff.loss.LossReduce; import org.nd4j.autodiff.samediff.SDVariable; import org.nd4j.autodiff.samediff.SameDiff; -import org.nd4j.base.Preconditions; -import org.nd4j.linalg.api.buffer.DataType; import org.nd4j.linalg.api.ndarray.INDArray; import org.nd4j.linalg.api.ops.impl.loss.bp.AbsoluteDifferenceLossBp; diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/loss/CosineDistanceLoss.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/loss/CosineDistanceLoss.java index 432910391..21ac3d25c 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/loss/CosineDistanceLoss.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/loss/CosineDistanceLoss.java @@ -21,8 +21,6 @@ import org.nd4j.autodiff.samediff.SDVariable; import org.nd4j.autodiff.samediff.SameDiff; import org.nd4j.linalg.api.ndarray.INDArray; import org.nd4j.linalg.api.ops.impl.loss.bp.CosineDistanceLossBp; - -import java.util.Arrays; import java.util.List; /** diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/loss/HingeLoss.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/loss/HingeLoss.java index d021623d5..3f8613ac5 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/loss/HingeLoss.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/loss/HingeLoss.java @@ -22,7 +22,6 @@ import org.nd4j.autodiff.samediff.SameDiff; import org.nd4j.linalg.api.ndarray.INDArray; import org.nd4j.linalg.api.ops.impl.loss.bp.HingeLossBp; -import java.util.Arrays; import java.util.List; /** diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/loss/HuberLoss.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/loss/HuberLoss.java index acb74c04c..564e726b3 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/loss/HuberLoss.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/loss/HuberLoss.java @@ -23,7 +23,6 @@ import org.nd4j.base.Preconditions; import org.nd4j.linalg.api.ndarray.INDArray; import org.nd4j.linalg.api.ops.impl.loss.bp.HuberLossBp; -import java.util.Arrays; import java.util.List; /** diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/loss/MeanPairwiseSquaredErrorLoss.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/loss/MeanPairwiseSquaredErrorLoss.java index 676eec5e0..b6bfc6748 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/loss/MeanPairwiseSquaredErrorLoss.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/loss/MeanPairwiseSquaredErrorLoss.java @@ -22,7 +22,6 @@ import org.nd4j.autodiff.samediff.SameDiff; import org.nd4j.linalg.api.ndarray.INDArray; import org.nd4j.linalg.api.ops.impl.loss.bp.MeanPairwiseSquaredErrorLossBp; -import java.util.Arrays; import java.util.List; /** diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/loss/MeanSquaredErrorLoss.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/loss/MeanSquaredErrorLoss.java index c40d9e432..2bf1c66db 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/loss/MeanSquaredErrorLoss.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/loss/MeanSquaredErrorLoss.java @@ -22,7 +22,6 @@ import org.nd4j.autodiff.samediff.SameDiff; import org.nd4j.linalg.api.ndarray.INDArray; import org.nd4j.linalg.api.ops.impl.loss.bp.MeanSquaredErrorLossBp; -import java.util.Arrays; import java.util.List; /** diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/loss/bp/AbsoluteDifferenceLossBp.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/loss/bp/AbsoluteDifferenceLossBp.java index 54ba231bf..5e3802678 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/loss/bp/AbsoluteDifferenceLossBp.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/loss/bp/AbsoluteDifferenceLossBp.java @@ -19,7 +19,6 @@ package org.nd4j.linalg.api.ops.impl.loss.bp; import org.nd4j.autodiff.loss.LossReduce; import org.nd4j.autodiff.samediff.SDVariable; import org.nd4j.autodiff.samediff.SameDiff; -import org.nd4j.linalg.api.ops.impl.loss.BaseLoss; import java.util.List; diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/loss/bp/HingeLossBp.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/loss/bp/HingeLossBp.java index cdc267f1f..8637c2fc7 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/loss/bp/HingeLossBp.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/loss/bp/HingeLossBp.java @@ -19,7 +19,6 @@ package org.nd4j.linalg.api.ops.impl.loss.bp; import org.nd4j.autodiff.loss.LossReduce; import org.nd4j.autodiff.samediff.SDVariable; import org.nd4j.autodiff.samediff.SameDiff; -import org.nd4j.linalg.api.ops.impl.loss.BaseLoss; /** * Hinge loss diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/loss/bp/LogPoissonLossBp.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/loss/bp/LogPoissonLossBp.java index 5bf5058fd..299aef89b 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/loss/bp/LogPoissonLossBp.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/loss/bp/LogPoissonLossBp.java @@ -16,6 +16,7 @@ package org.nd4j.linalg.api.ops.impl.loss.bp; +import lombok.NoArgsConstructor; import org.nd4j.autodiff.loss.LossReduce; import org.nd4j.autodiff.samediff.SDVariable; import org.nd4j.autodiff.samediff.SameDiff; @@ -25,6 +26,7 @@ import org.nd4j.autodiff.samediff.SameDiff; * * @author Paul Dubs */ +@NoArgsConstructor public class LogPoissonLossBp extends BaseLossBp { private boolean full = false; @@ -39,9 +41,7 @@ public class LogPoissonLossBp extends BaseLossBp { addArgs(); } - public LogPoissonLossBp(){ } - - + @Override protected void addArgs(){ super.addArgs(); if(full){ diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/loss/bp/MeanSquaredErrorLossBp.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/loss/bp/MeanSquaredErrorLossBp.java index 5250f6fb1..9be5038de 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/loss/bp/MeanSquaredErrorLossBp.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/loss/bp/MeanSquaredErrorLossBp.java @@ -19,7 +19,6 @@ package org.nd4j.linalg.api.ops.impl.loss.bp; import org.nd4j.autodiff.loss.LossReduce; import org.nd4j.autodiff.samediff.SDVariable; import org.nd4j.autodiff.samediff.SameDiff; -import org.nd4j.linalg.api.ops.impl.loss.BaseLoss; /** * Mean squared error loss diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/reduce/bool/IsInf.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/reduce/bool/IsInf.java index 5dfc23f8e..4ebb8701d 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/reduce/bool/IsInf.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/reduce/bool/IsInf.java @@ -18,7 +18,6 @@ package org.nd4j.linalg.api.ops.impl.reduce.bool; import org.nd4j.autodiff.samediff.SDVariable; import org.nd4j.autodiff.samediff.SameDiff; -import org.nd4j.imports.NoOpNameFoundException; import org.nd4j.linalg.api.ndarray.INDArray; import org.nd4j.linalg.api.ops.BaseReduceBoolOp; diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/reduce/bp/VarianceBp.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/reduce/bp/VarianceBp.java index 767392c97..3ab61e96d 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/reduce/bp/VarianceBp.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/reduce/bp/VarianceBp.java @@ -16,6 +16,7 @@ package org.nd4j.linalg.api.ops.impl.reduce.bp; +import lombok.NoArgsConstructor; import org.nd4j.autodiff.samediff.SDVariable; import org.nd4j.autodiff.samediff.SameDiff; import org.nd4j.linalg.api.ndarray.INDArray; @@ -26,7 +27,7 @@ import org.nd4j.linalg.api.ndarray.INDArray; * * @author Alex Black */ - +@NoArgsConstructor public class VarianceBp extends BaseReductionBp { private boolean biasCorrected; @@ -43,8 +44,6 @@ public class VarianceBp extends BaseReductionBp { addTArgument(biasCorrected ? 1.0 : 0.0); } - public VarianceBp(){} - @Override public String opName() { return "reduce_variance_bp"; diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/reduce/floating/Mean.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/reduce/floating/Mean.java index 6309ccf28..a4e27e42f 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/reduce/floating/Mean.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/reduce/floating/Mean.java @@ -22,7 +22,6 @@ import org.nd4j.linalg.api.ndarray.INDArray; import org.nd4j.linalg.api.ops.BaseReduceFloatOp; import org.nd4j.linalg.api.ops.impl.reduce.bp.MeanBp; -import java.util.Collections; import java.util.List; /** diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/reduce/longer/CountNonZero.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/reduce/longer/CountNonZero.java index 7376b0708..cb1de4765 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/reduce/longer/CountNonZero.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/reduce/longer/CountNonZero.java @@ -19,7 +19,6 @@ package org.nd4j.linalg.api.ops.impl.reduce.longer; import lombok.NoArgsConstructor; import org.nd4j.autodiff.samediff.SDVariable; import org.nd4j.autodiff.samediff.SameDiff; -import org.nd4j.imports.NoOpNameFoundException; import org.nd4j.linalg.api.ndarray.INDArray; import org.nd4j.linalg.api.ops.BaseReduceLongOp; diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/shape/GatherNd.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/shape/GatherNd.java index 7ac8429c8..ff38c382e 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/shape/GatherNd.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/shape/GatherNd.java @@ -17,13 +17,11 @@ package org.nd4j.linalg.api.ops.impl.shape; import lombok.NoArgsConstructor; -import org.apache.commons.lang3.ArrayUtils; import org.nd4j.autodiff.samediff.SDVariable; import org.nd4j.autodiff.samediff.SameDiff; import org.nd4j.linalg.api.buffer.DataType; import org.nd4j.linalg.api.ndarray.INDArray; import org.nd4j.linalg.api.ops.DynamicCustomOp; -import org.nd4j.linalg.util.ArrayUtil; import java.util.Collections; import java.util.List; diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/shape/Linspace.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/shape/Linspace.java index f83d61c0d..a08b30f74 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/shape/Linspace.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/shape/Linspace.java @@ -18,7 +18,6 @@ package org.nd4j.linalg.api.ops.impl.shape; import lombok.NonNull; -import org.apache.commons.lang3.NotImplementedException; import org.nd4j.autodiff.samediff.SDVariable; import org.nd4j.autodiff.samediff.SameDiff; import org.nd4j.imports.NoOpNameFoundException; @@ -26,7 +25,6 @@ import org.nd4j.imports.graphmapper.tf.TFGraphMapper; import org.nd4j.linalg.api.buffer.DataType; import org.nd4j.linalg.api.ndarray.INDArray; import org.nd4j.linalg.api.ops.DynamicCustomOp; -import org.nd4j.linalg.factory.Nd4j; import org.tensorflow.framework.AttrValue; import org.tensorflow.framework.GraphDef; import org.tensorflow.framework.NodeDef; diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/summarystats/Variance.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/summarystats/Variance.java index 64948880c..9f69f8e6a 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/summarystats/Variance.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/summarystats/Variance.java @@ -165,10 +165,7 @@ public class Variance extends BaseReduceOp { return false; INDArray z = oc != null ? oc.getOutputArray(0) : z(); - if (z != null && !z.isR()) - return false; - - return true; + return !(z != null && !z.isR()); } @Override @@ -201,6 +198,7 @@ public class Variance extends BaseReduceOp { return Type.VARIANCE; } + @Override public List calculateOutputDataTypes(List dataTypes){ Preconditions.checkState(dataTypes != null && dataTypes.size() == 1, "Expected exactly 1 input datatype for %s, got input %s", getClass(), dataTypes); //Variance and stdev reduction: Always FP out, but if FP in is float/double/half then it's float/double/half out diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/Histogram.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/Histogram.java index 31937ded7..fdd48e133 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/Histogram.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/Histogram.java @@ -19,7 +19,6 @@ package org.nd4j.linalg.api.ops.impl.transforms; import org.nd4j.base.Preconditions; import org.nd4j.linalg.api.ndarray.INDArray; import org.nd4j.linalg.api.ops.DynamicCustomOp; -import org.nd4j.linalg.factory.Nd4j; /** * Histogram op wrapper diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/bool/IsFinite.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/bool/IsFinite.java index 8cf81febf..a8be9803a 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/bool/IsFinite.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/bool/IsFinite.java @@ -21,7 +21,6 @@ import org.nd4j.autodiff.samediff.SDVariable; import org.nd4j.autodiff.samediff.SameDiff; import org.nd4j.linalg.api.ndarray.INDArray; import org.nd4j.linalg.api.ops.BaseTransformBoolOp; -import org.nd4j.linalg.api.ops.BaseTransformOp; import java.util.Collections; import java.util.List; diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/bool/IsNaN.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/bool/IsNaN.java index 9f8e9ea74..d5ff3cd6a 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/bool/IsNaN.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/bool/IsNaN.java @@ -17,12 +17,10 @@ package org.nd4j.linalg.api.ops.impl.transforms.bool; import lombok.NoArgsConstructor; -import org.nd4j.autodiff.functions.DifferentialFunction; import org.nd4j.autodiff.samediff.SDVariable; import org.nd4j.autodiff.samediff.SameDiff; import org.nd4j.linalg.api.ndarray.INDArray; import org.nd4j.linalg.api.ops.BaseTransformBoolOp; -import org.nd4j.linalg.api.ops.BaseTransformOp; import java.util.Collections; import java.util.List; diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/bool/MatchConditionTransform.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/bool/MatchConditionTransform.java index b3810ba15..d0836adc9 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/bool/MatchConditionTransform.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/bool/MatchConditionTransform.java @@ -17,13 +17,11 @@ package org.nd4j.linalg.api.ops.impl.transforms.bool; import lombok.NonNull; -import org.nd4j.autodiff.functions.DifferentialFunction; import org.nd4j.autodiff.samediff.SDVariable; import org.nd4j.autodiff.samediff.SameDiff; import org.nd4j.imports.NoOpNameFoundException; import org.nd4j.linalg.api.ndarray.INDArray; import org.nd4j.linalg.api.ops.BaseTransformBoolOp; -import org.nd4j.linalg.api.ops.BaseTransformOp; import org.nd4j.linalg.factory.Nd4j; import org.nd4j.linalg.indexing.conditions.Condition; diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/custom/InvertPermutation.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/custom/InvertPermutation.java index 9612c4dea..dbf3bfdd4 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/custom/InvertPermutation.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/custom/InvertPermutation.java @@ -25,7 +25,6 @@ import org.nd4j.linalg.api.buffer.DataType; import org.nd4j.linalg.api.ndarray.INDArray; import org.nd4j.linalg.api.ops.impl.transforms.BaseDynamicTransformOp; -import java.util.Arrays; import java.util.Collections; import java.util.List; diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/custom/MaximumBp.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/custom/MaximumBp.java index 92fb3b0eb..75683c72e 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/custom/MaximumBp.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/custom/MaximumBp.java @@ -19,7 +19,6 @@ import lombok.NoArgsConstructor; import lombok.NonNull; import org.nd4j.autodiff.samediff.SDVariable; import org.nd4j.autodiff.samediff.SameDiff; -import org.nd4j.base.Preconditions; import org.nd4j.linalg.api.buffer.DataType; import org.nd4j.linalg.api.ops.DynamicCustomOp; diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/gradient/CubeDerivative.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/gradient/CubeDerivative.java index af9985e89..60b5d9161 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/gradient/CubeDerivative.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/gradient/CubeDerivative.java @@ -20,7 +20,6 @@ import org.nd4j.autodiff.samediff.SDVariable; import org.nd4j.autodiff.samediff.SameDiff; import org.nd4j.imports.NoOpNameFoundException; import org.nd4j.linalg.api.ndarray.INDArray; -import org.nd4j.linalg.api.ops.BaseTransformOp; import org.nd4j.linalg.api.ops.BaseTransformStrictOp; import java.util.List; diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/gradient/HardSigmoidDerivative.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/gradient/HardSigmoidDerivative.java index c7328a92b..75c8a25fb 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/gradient/HardSigmoidDerivative.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/gradient/HardSigmoidDerivative.java @@ -21,7 +21,6 @@ import org.nd4j.autodiff.samediff.SDVariable; import org.nd4j.autodiff.samediff.SameDiff; import org.nd4j.imports.NoOpNameFoundException; import org.nd4j.linalg.api.ndarray.INDArray; -import org.nd4j.linalg.api.ops.BaseTransformOp; import org.nd4j.linalg.api.ops.BaseTransformStrictOp; import java.util.List; diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/gradient/HardTanhDerivative.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/gradient/HardTanhDerivative.java index 2ca198506..6bf3a95ac 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/gradient/HardTanhDerivative.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/gradient/HardTanhDerivative.java @@ -22,10 +22,8 @@ import org.nd4j.autodiff.samediff.SDVariable; import org.nd4j.autodiff.samediff.SameDiff; import org.nd4j.imports.NoOpNameFoundException; import org.nd4j.linalg.api.ndarray.INDArray; -import org.nd4j.linalg.api.ops.BaseTransformOp; import org.nd4j.linalg.api.ops.BaseTransformStrictOp; -import java.util.Arrays; import java.util.Collections; import java.util.List; diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/pairwise/arithmetic/MergeAddOp.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/pairwise/arithmetic/MergeAddOp.java index 0d634766e..6edf4d002 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/pairwise/arithmetic/MergeAddOp.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/pairwise/arithmetic/MergeAddOp.java @@ -18,18 +18,14 @@ package org.nd4j.linalg.api.ops.impl.transforms.pairwise.arithmetic; import lombok.NoArgsConstructor; import lombok.NonNull; -import org.apache.commons.lang3.ArrayUtils; import org.nd4j.autodiff.samediff.SDVariable; import org.nd4j.autodiff.samediff.SameDiff; import org.nd4j.base.Preconditions; import org.nd4j.linalg.api.buffer.DataType; import org.nd4j.linalg.api.ndarray.INDArray; import org.nd4j.linalg.api.ops.impl.transforms.BaseDynamicTransformOp; -import org.nd4j.linalg.api.ops.impl.transforms.custom.MaximumBp; import org.nd4j.linalg.api.ops.impl.transforms.pairwise.arithmetic.bp.MergeAddBp; -import org.nd4j.linalg.util.ArrayUtil; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/pairwise/arithmetic/bp/MergeAddBp.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/pairwise/arithmetic/bp/MergeAddBp.java index b0403ecff..8df28f40b 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/pairwise/arithmetic/bp/MergeAddBp.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/pairwise/arithmetic/bp/MergeAddBp.java @@ -24,7 +24,6 @@ import org.nd4j.linalg.api.buffer.DataType; import org.nd4j.linalg.api.ops.DynamicCustomOp; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; @NoArgsConstructor diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/same/Cube.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/same/Cube.java index b4550cb4e..1a7e66dc2 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/same/Cube.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/same/Cube.java @@ -16,18 +16,13 @@ package org.nd4j.linalg.api.ops.impl.transforms.same; -import java.util.Collections; - import lombok.NoArgsConstructor; import org.nd4j.autodiff.samediff.SDVariable; import org.nd4j.autodiff.samediff.SameDiff; import org.nd4j.imports.NoOpNameFoundException; import org.nd4j.linalg.api.ndarray.INDArray; -import org.nd4j.linalg.api.ops.BaseTransformOp; import org.nd4j.linalg.api.ops.BaseTransformSameOp; import org.nd4j.linalg.api.ops.impl.transforms.gradient.CubeBp; - -import java.util.Arrays; import java.util.List; /** diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/same/Max.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/same/Max.java index f5aec6b48..9db42dcfc 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/same/Max.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/same/Max.java @@ -21,10 +21,8 @@ import org.nd4j.autodiff.samediff.SameDiff; import org.nd4j.imports.NoOpNameFoundException; import org.nd4j.linalg.api.ndarray.INDArray; import org.nd4j.linalg.api.ops.BaseTransformSameOp; -import org.nd4j.linalg.api.ops.impl.reduce.bp.MaxBp; import org.nd4j.linalg.api.ops.impl.transforms.custom.MaximumBp; -import java.util.Collections; import java.util.List; /** diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/ACos.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/ACos.java index 44dca1ed1..88fae5f99 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/ACos.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/ACos.java @@ -21,8 +21,6 @@ import org.nd4j.autodiff.samediff.SDVariable; import org.nd4j.autodiff.samediff.SameDiff; import org.nd4j.imports.NoOpNameFoundException; import org.nd4j.linalg.api.ndarray.INDArray; -import org.nd4j.linalg.api.ops.BaseTransformFloatOp; -import org.nd4j.linalg.api.ops.BaseTransformOp; import org.nd4j.linalg.api.ops.BaseTransformStrictOp; import java.util.Arrays; diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/ACosh.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/ACosh.java index a8d9f12ad..7273454bc 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/ACosh.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/ACosh.java @@ -21,8 +21,6 @@ import org.nd4j.autodiff.samediff.SDVariable; import org.nd4j.autodiff.samediff.SameDiff; import org.nd4j.imports.NoOpNameFoundException; import org.nd4j.linalg.api.ndarray.INDArray; -import org.nd4j.linalg.api.ops.BaseTransformFloatOp; -import org.nd4j.linalg.api.ops.BaseTransformOp; import org.nd4j.linalg.api.ops.BaseTransformStrictOp; import java.util.Arrays; diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/ASin.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/ASin.java index fc514a415..9174d59a6 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/ASin.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/ASin.java @@ -21,11 +21,8 @@ import org.nd4j.autodiff.samediff.SDVariable; import org.nd4j.autodiff.samediff.SameDiff; import org.nd4j.imports.NoOpNameFoundException; import org.nd4j.linalg.api.ndarray.INDArray; -import org.nd4j.linalg.api.ops.BaseTransformFloatOp; -import org.nd4j.linalg.api.ops.BaseTransformOp; import org.nd4j.linalg.api.ops.BaseTransformStrictOp; -import java.util.Arrays; import java.util.Collections; import java.util.List; diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/ASinh.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/ASinh.java index 25f20e011..f394232b1 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/ASinh.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/ASinh.java @@ -20,8 +20,6 @@ import org.nd4j.autodiff.samediff.SDVariable; import org.nd4j.autodiff.samediff.SameDiff; import org.nd4j.imports.NoOpNameFoundException; import org.nd4j.linalg.api.ndarray.INDArray; -import org.nd4j.linalg.api.ops.BaseTransformFloatOp; -import org.nd4j.linalg.api.ops.BaseTransformOp; import org.nd4j.linalg.api.ops.BaseTransformStrictOp; import java.util.Arrays; diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/ATan.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/ATan.java index a7a741759..5d311cb5e 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/ATan.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/ATan.java @@ -21,8 +21,6 @@ import org.nd4j.autodiff.samediff.SDVariable; import org.nd4j.autodiff.samediff.SameDiff; import org.nd4j.imports.NoOpNameFoundException; import org.nd4j.linalg.api.ndarray.INDArray; -import org.nd4j.linalg.api.ops.BaseTransformFloatOp; -import org.nd4j.linalg.api.ops.BaseTransformOp; import org.nd4j.linalg.api.ops.BaseTransformStrictOp; import java.util.Arrays; diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/ATanh.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/ATanh.java index b73884135..df094b295 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/ATanh.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/ATanh.java @@ -20,8 +20,6 @@ import org.nd4j.autodiff.samediff.SDVariable; import org.nd4j.autodiff.samediff.SameDiff; import org.nd4j.imports.NoOpNameFoundException; import org.nd4j.linalg.api.ndarray.INDArray; -import org.nd4j.linalg.api.ops.BaseTransformFloatOp; -import org.nd4j.linalg.api.ops.BaseTransformOp; import org.nd4j.linalg.api.ops.BaseTransformStrictOp; import java.util.Arrays; diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/Cos.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/Cos.java index 35ed040c2..2efe4020b 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/Cos.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/Cos.java @@ -21,8 +21,6 @@ import org.nd4j.autodiff.samediff.SDVariable; import org.nd4j.autodiff.samediff.SameDiff; import org.nd4j.imports.NoOpNameFoundException; import org.nd4j.linalg.api.ndarray.INDArray; -import org.nd4j.linalg.api.ops.BaseTransformFloatOp; -import org.nd4j.linalg.api.ops.BaseTransformOp; import org.nd4j.linalg.api.ops.BaseTransformStrictOp; import java.util.Arrays; diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/Cosh.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/Cosh.java index 5144315da..dd942d898 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/Cosh.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/Cosh.java @@ -21,8 +21,6 @@ import org.nd4j.autodiff.samediff.SDVariable; import org.nd4j.autodiff.samediff.SameDiff; import org.nd4j.imports.NoOpNameFoundException; import org.nd4j.linalg.api.ndarray.INDArray; -import org.nd4j.linalg.api.ops.BaseTransformFloatOp; -import org.nd4j.linalg.api.ops.BaseTransformOp; import org.nd4j.linalg.api.ops.BaseTransformStrictOp; import java.util.Arrays; diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/ELU.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/ELU.java index cc3a5e116..1c3c430d1 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/ELU.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/ELU.java @@ -25,7 +25,6 @@ import org.nd4j.linalg.api.ndarray.INDArray; import org.nd4j.linalg.api.ops.DynamicCustomOp; import org.nd4j.linalg.api.ops.impl.transforms.gradient.EluBp; -import java.util.Collections; import java.util.List; /** diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/HardTanh.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/HardTanh.java index fc44f3c22..e0386cb37 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/HardTanh.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/HardTanh.java @@ -16,18 +16,13 @@ package org.nd4j.linalg.api.ops.impl.transforms.strict; -import java.util.Collections; - import lombok.NoArgsConstructor; import org.nd4j.autodiff.samediff.SDVariable; import org.nd4j.autodiff.samediff.SameDiff; import org.nd4j.linalg.api.ndarray.INDArray; -import org.nd4j.linalg.api.ops.BaseTransformFloatOp; -import org.nd4j.linalg.api.ops.BaseTransformOp; import org.nd4j.linalg.api.ops.BaseTransformStrictOp; import org.nd4j.linalg.api.ops.impl.transforms.gradient.HardTanhBp; -import java.util.Arrays; import java.util.List; /** diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/LogSigmoid.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/LogSigmoid.java index 6a118a062..33041438c 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/LogSigmoid.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/strict/LogSigmoid.java @@ -20,12 +20,9 @@ import lombok.NoArgsConstructor; import org.nd4j.autodiff.samediff.SDVariable; import org.nd4j.autodiff.samediff.SameDiff; import org.nd4j.linalg.api.ndarray.INDArray; -import org.nd4j.linalg.api.ops.BaseTransformFloatOp; -import org.nd4j.linalg.api.ops.BaseTransformOp; import org.nd4j.linalg.api.ops.BaseTransformStrictOp; import org.nd4j.linalg.api.ops.impl.transforms.gradient.SigmoidDerivative; -import java.util.Arrays; import java.util.Collections; import java.util.List; diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/random/impl/BinomialDistribution.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/random/impl/BinomialDistribution.java index 93e4e3c66..29a17aa29 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/random/impl/BinomialDistribution.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/random/impl/BinomialDistribution.java @@ -47,6 +47,7 @@ public class BinomialDistribution extends BaseRandomOp { public BinomialDistribution(SameDiff sd, int trials, double probability, DataType dataType, long[] shape){ this(sd, trials, probability, shape); + super.dataType = dataType; } public BinomialDistribution(int trials, double probability, DataType dt, long[] shape){ diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/random/impl/DropOut.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/random/impl/DropOut.java index 742e28113..e94e775eb 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/random/impl/DropOut.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/random/impl/DropOut.java @@ -20,13 +20,9 @@ import lombok.NoArgsConstructor; import lombok.NonNull; import org.nd4j.autodiff.samediff.SDVariable; import org.nd4j.autodiff.samediff.SameDiff; -import org.nd4j.imports.NoOpNameFoundException; import org.nd4j.linalg.api.ndarray.INDArray; import org.nd4j.linalg.api.ops.random.BaseRandomOp; - -import java.util.LinkedHashMap; import java.util.List; -import java.util.Map; /** * DropOut implementation as Op diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/dataset/DataSet.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/dataset/DataSet.java index 5cfecc6fe..1a4e97d22 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/dataset/DataSet.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/dataset/DataSet.java @@ -329,7 +329,7 @@ public class DataSet implements org.nd4j.linalg.dataset.api.DataSet { dos.flush(); dos.close(); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); } } diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/dataset/MiniBatchFileDataSetIterator.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/dataset/MiniBatchFileDataSetIterator.java index 424119e32..3673e3577 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/dataset/MiniBatchFileDataSetIterator.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/dataset/MiniBatchFileDataSetIterator.java @@ -16,6 +16,7 @@ package org.nd4j.linalg.dataset; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.FileUtils; import org.nd4j.linalg.dataset.api.DataSetPreProcessor; import org.nd4j.linalg.dataset.api.iterator.DataSetIterator; @@ -23,6 +24,7 @@ import org.nd4j.linalg.factory.Nd4j; import org.nd4j.linalg.indexing.NDArrayIndex; import org.nd4j.linalg.util.ND4JFileUtils; +import javax.annotation.processing.SupportedAnnotationTypes; import java.io.*; import java.util.ArrayList; import java.util.List; @@ -32,6 +34,7 @@ import java.util.UUID; * Mini batch file datasetiterator * auto partitions a dataset in to mini batches */ +@Slf4j public class MiniBatchFileDataSetIterator implements DataSetIterator { private int batchSize; private List paths; @@ -75,7 +78,7 @@ public class MiniBatchFileDataSetIterator implements DataSetIterator { try { FileUtils.deleteDirectory(MiniBatchFileDataSetIterator.this.rootDir); } catch (IOException e) { - e.printStackTrace(); + log.error("",e); } } })); diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/dataset/api/preprocessor/AbstractDataSetNormalizer.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/dataset/api/preprocessor/AbstractDataSetNormalizer.java index 1eacd626e..5dd6bd641 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/dataset/api/preprocessor/AbstractDataSetNormalizer.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/dataset/api/preprocessor/AbstractDataSetNormalizer.java @@ -154,13 +154,13 @@ public abstract class AbstractDataSetNormalizer exten @Override public void transform(INDArray features, INDArray featuresMask) { - S featureStats = getFeatureStats(); + S featureStatsLocal = getFeatureStats(); - if(featureStats == null){ + if(featureStatsLocal == null){ throw new ND4JIllegalStateException("Features statistics were not yet calculated. Make sure to run fit() first."); } - strategy.preProcess(features, featuresMask, featureStats); } + strategy.preProcess(features, featuresMask, featureStatsLocal); } /** * Transform the labels. If {@link #isFitLabel()} == false, this is a no-op diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/dataset/api/preprocessor/CompositeDataSetPreProcessor.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/dataset/api/preprocessor/CompositeDataSetPreProcessor.java index 14a8bf489..7be4d7d3b 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/dataset/api/preprocessor/CompositeDataSetPreProcessor.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/dataset/api/preprocessor/CompositeDataSetPreProcessor.java @@ -19,8 +19,6 @@ package org.nd4j.linalg.dataset.api.preprocessor; import org.nd4j.base.Preconditions; import org.nd4j.linalg.dataset.api.DataSet; import org.nd4j.linalg.dataset.api.DataSetPreProcessor; -import org.nd4j.linalg.dataset.api.MultiDataSet; -import org.nd4j.linalg.dataset.api.MultiDataSetPreProcessor; /** * A simple Composite DataSetPreProcessor - allows you to apply multiple DataSetPreProcessors sequentially diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/factory/Nd4j.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/factory/Nd4j.java index 2b1021742..6c371fe01 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/factory/Nd4j.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/factory/Nd4j.java @@ -16,6 +16,7 @@ package org.nd4j.linalg.factory; +import lombok.extern.slf4j.Slf4j; import org.nd4j.linalg.factory.ops.*; import org.nd4j.shade.guava.primitives.Ints; import org.nd4j.shade.guava.primitives.Longs; @@ -112,6 +113,7 @@ import java.util.logging.Logger; * * @author Adam Gibson */ +@Slf4j public class Nd4j { /** @@ -2460,7 +2462,7 @@ public class Nd4j { //noinspection ConstantConditions newArr.addi((format.parse(entries[0])).doubleValue()); } catch (ParseException e) { - e.printStackTrace(); + log.error("",e); } } else { Preconditions.checkState(entries.length == theShape[rank-1], "Invalid number of entries - format does not match expected shape." + @@ -2470,7 +2472,7 @@ public class Nd4j { BigDecimal number = (BigDecimal) format.parse(entries[i]); subsetArr[i] = number.doubleValue(); } catch (ParseException e) { - e.printStackTrace(); + log.error("",e); } } INDArray subTensor = Nd4j.create(subsetArr, new long[]{subsetArr.length}, Nd4j.defaultFloatingPointType()); diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/factory/Nd4jBackend.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/factory/Nd4jBackend.java index 7575c1238..c3b9ea558 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/factory/Nd4jBackend.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/factory/Nd4jBackend.java @@ -196,7 +196,7 @@ public abstract class Nd4jBackend { try { Nd4jContext.getInstance().updateProperties(backend.getConfigurationResource().getInputStream()); } catch (IOException e) { - e.printStackTrace(); + log.error("",e); } if(logInit) { diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/lossfunctions/impl/LossSparseMCXENT.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/lossfunctions/impl/LossSparseMCXENT.java index f472fae5f..c6879a133 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/lossfunctions/impl/LossSparseMCXENT.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/lossfunctions/impl/LossSparseMCXENT.java @@ -22,15 +22,9 @@ import lombok.Getter; import lombok.Setter; import org.nd4j.base.Preconditions; import org.nd4j.linalg.activations.IActivation; -import org.nd4j.linalg.activations.impl.ActivationSoftmax; import org.nd4j.linalg.api.ndarray.INDArray; import org.nd4j.linalg.api.ops.impl.shape.OneHot; import org.nd4j.linalg.factory.Nd4j; -import org.nd4j.linalg.indexing.BooleanIndexing; -import org.nd4j.linalg.indexing.conditions.Conditions; -import org.nd4j.linalg.lossfunctions.ILossFunction; -import org.nd4j.linalg.lossfunctions.LossUtil; -import org.nd4j.linalg.ops.transforms.Transforms; import org.nd4j.linalg.primitives.Pair; import org.nd4j.serde.jackson.shaded.NDArrayTextDeSerializer; import org.nd4j.serde.jackson.shaded.NDArrayTextSerializer; diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/ops/transforms/Transforms.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/ops/transforms/Transforms.java index ad887789d..c63289e2c 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/ops/transforms/Transforms.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/ops/transforms/Transforms.java @@ -793,8 +793,9 @@ public class Transforms { * @return */ public static INDArray lessThanOrEqual(INDArray first, INDArray ndArray, boolean dup) { - return Nd4j.getExecutioner().exec(new LessThanOrEqual(first, ndArray, Nd4j.createUninitialized(DataType.BOOL, first.shape(), first.ordering())))[0]; - + val op = dup ? new LessThanOrEqual(first, ndArray, Nd4j.createUninitialized(DataType.BOOL, first.shape(), first.ordering())) : + new LessThanOrEqual(first, ndArray); + return Nd4j.getExecutioner().exec(op)[0]; } @@ -805,7 +806,9 @@ public class Transforms { * @return */ public static INDArray greaterThanOrEqual(INDArray first, INDArray ndArray, boolean dup) { - return Nd4j.getExecutioner().exec(new GreaterThanOrEqual(first, ndArray, Nd4j.createUninitialized(DataType.BOOL, first.shape(), first.ordering())))[0]; + val op = dup ? new GreaterThanOrEqual(first, ndArray, Nd4j.createUninitialized(DataType.BOOL, first.shape(), first.ordering())) : + new GreaterThanOrEqual(first, ndArray); + return Nd4j.getExecutioner().exec(op)[0]; } diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/serde/binary/BinarySerde.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/serde/binary/BinarySerde.java index ecc4cfe18..fc6f13922 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/serde/binary/BinarySerde.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/serde/binary/BinarySerde.java @@ -262,7 +262,7 @@ public class BinarySerde { try (WritableByteChannel channel = Channels.newChannel(outputStream)) { channel.write(buffer); } catch (IOException e) { - e.printStackTrace(); + log.error("",e); } } diff --git a/nd4j/nd4j-backends/nd4j-backend-impls/nd4j-cuda/src/main/java/org/nd4j/jita/constant/ProtectedCudaConstantHandler.java b/nd4j/nd4j-backends/nd4j-backend-impls/nd4j-cuda/src/main/java/org/nd4j/jita/constant/ProtectedCudaConstantHandler.java index af7e33f9c..0b2f1fca1 100644 --- a/nd4j/nd4j-backends/nd4j-backend-impls/nd4j-cuda/src/main/java/org/nd4j/jita/constant/ProtectedCudaConstantHandler.java +++ b/nd4j/nd4j-backends/nd4j-backend-impls/nd4j-cuda/src/main/java/org/nd4j/jita/constant/ProtectedCudaConstantHandler.java @@ -39,6 +39,7 @@ import org.nd4j.linalg.util.ArrayUtil; import org.nd4j.nativeblas.NativeOpsHolder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import java.util.HashMap; import java.util.Map; @@ -49,6 +50,7 @@ import java.util.concurrent.atomic.AtomicLong; /** * Created by raver on 08.06.2016. */ +@Slf4j public class ProtectedCudaConstantHandler implements ConstantHandler { private static ProtectedCudaConstantHandler ourInstance = new ProtectedCudaConstantHandler(); diff --git a/nd4j/nd4j-backends/nd4j-backend-impls/nd4j-cuda/src/main/java/org/nd4j/linalg/jcublas/CublasPointer.java b/nd4j/nd4j-backends/nd4j-backend-impls/nd4j-cuda/src/main/java/org/nd4j/linalg/jcublas/CublasPointer.java index fe5f51080..d7109f5cb 100644 --- a/nd4j/nd4j-backends/nd4j-backend-impls/nd4j-cuda/src/main/java/org/nd4j/linalg/jcublas/CublasPointer.java +++ b/nd4j/nd4j-backends/nd4j-backend-impls/nd4j-cuda/src/main/java/org/nd4j/linalg/jcublas/CublasPointer.java @@ -22,6 +22,7 @@ import org.nd4j.jita.allocator.impl.AtomicAllocator; import org.nd4j.linalg.api.ndarray.INDArray; import org.nd4j.linalg.jcublas.buffer.JCudaBuffer; import org.nd4j.linalg.jcublas.context.CudaContext; +import lombok.extern.slf4j.Slf4j; /** * Wraps the allocation @@ -29,6 +30,7 @@ import org.nd4j.linalg.jcublas.context.CudaContext; * @author bam4d * */ +@Slf4j public class CublasPointer implements AutoCloseable { /** @@ -166,7 +168,7 @@ public class CublasPointer implements AutoCloseable { try { pointer.close(); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); } } } diff --git a/nd4j/nd4j-backends/nd4j-backend-impls/nd4j-cuda/src/main/java/org/nd4j/linalg/jcublas/buffer/CudaFloatDataBuffer.java b/nd4j/nd4j-backends/nd4j-backend-impls/nd4j-cuda/src/main/java/org/nd4j/linalg/jcublas/buffer/CudaFloatDataBuffer.java index a6aca24c2..cec6ca762 100644 --- a/nd4j/nd4j-backends/nd4j-backend-impls/nd4j-cuda/src/main/java/org/nd4j/linalg/jcublas/buffer/CudaFloatDataBuffer.java +++ b/nd4j/nd4j-backends/nd4j-backend-impls/nd4j-cuda/src/main/java/org/nd4j/linalg/jcublas/buffer/CudaFloatDataBuffer.java @@ -22,6 +22,7 @@ import org.nd4j.linalg.api.buffer.DataBuffer; import org.nd4j.linalg.api.buffer.DataType; import org.nd4j.linalg.api.memory.MemoryWorkspace; import org.nd4j.linalg.util.ArrayUtil; +import lombok.extern.slf4j.Slf4j; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; @@ -33,6 +34,7 @@ import java.nio.ByteBuffer; * * @author Adam Gibson */ +@Slf4j public class CudaFloatDataBuffer extends BaseCudaDataBuffer { /** * Meant for creating another view of a buffer @@ -169,7 +171,7 @@ public class CudaFloatDataBuffer extends BaseCudaDataBuffer { try { dos.writeFloat(data[i]); } catch (IOException e) { - e.printStackTrace(); + log.error("",e); } return bos.toByteArray(); } diff --git a/nd4j/nd4j-backends/nd4j-tests/src/test/java/org/nd4j/linalg/profiling/OperationProfilerTests.java b/nd4j/nd4j-backends/nd4j-tests/src/test/java/org/nd4j/linalg/profiling/OperationProfilerTests.java index 22c6e3a52..8fff93cad 100644 --- a/nd4j/nd4j-backends/nd4j-tests/src/test/java/org/nd4j/linalg/profiling/OperationProfilerTests.java +++ b/nd4j/nd4j-backends/nd4j-tests/src/test/java/org/nd4j/linalg/profiling/OperationProfilerTests.java @@ -476,7 +476,7 @@ public class OperationProfilerTests extends BaseNd4jTest { Nd4j.exec(op); //Should trigger NaN panic fail(); } catch (Exception e){ - e.printStackTrace(); + log.error("",e); assertTrue(e.getMessage(), e.getMessage().contains("Inf")); } diff --git a/nd4j/nd4j-common/src/main/java/org/nd4j/linalg/io/AbstractFileResolvingResource.java b/nd4j/nd4j-common/src/main/java/org/nd4j/linalg/io/AbstractFileResolvingResource.java index c0b5aa853..b6dcc6bf8 100644 --- a/nd4j/nd4j-common/src/main/java/org/nd4j/linalg/io/AbstractFileResolvingResource.java +++ b/nd4j/nd4j-common/src/main/java/org/nd4j/linalg/io/AbstractFileResolvingResource.java @@ -28,6 +28,7 @@ import java.net.URLConnection; public abstract class AbstractFileResolvingResource extends AbstractResource { public AbstractFileResolvingResource() {} + @Override public File getFile() throws IOException { URL url = this.getURL(); return url.getProtocol().startsWith("vfs") @@ -35,6 +36,7 @@ public abstract class AbstractFileResolvingResource extends AbstractResource { : ResourceUtils.getFile(url, this.getDescription()); } + @Override protected File getFileForLastModifiedCheck() throws IOException { URL url = this.getURL(); if (ResourceUtils.isJarURL(url)) { @@ -53,6 +55,7 @@ public abstract class AbstractFileResolvingResource extends AbstractResource { : ResourceUtils.getFile(uri, this.getDescription()); } + @Override public boolean exists() { try { URL ex = this.getURL(); @@ -90,6 +93,7 @@ public abstract class AbstractFileResolvingResource extends AbstractResource { } } + @Override public boolean isReadable() { try { URL ex = this.getURL(); @@ -104,6 +108,7 @@ public abstract class AbstractFileResolvingResource extends AbstractResource { } } + @Override public long contentLength() throws IOException { URL url = this.getURL(); if (ResourceUtils.isFileURL(url)) { @@ -119,6 +124,7 @@ public abstract class AbstractFileResolvingResource extends AbstractResource { } } + @Override public long lastModified() throws IOException { URL url = this.getURL(); if (!ResourceUtils.isFileURL(url) && !ResourceUtils.isJarURL(url)) { diff --git a/nd4j/nd4j-common/src/main/java/org/nd4j/linalg/util/ArrayUtil.java b/nd4j/nd4j-common/src/main/java/org/nd4j/linalg/util/ArrayUtil.java index 39c09e627..cead401b3 100644 --- a/nd4j/nd4j-common/src/main/java/org/nd4j/linalg/util/ArrayUtil.java +++ b/nd4j/nd4j-common/src/main/java/org/nd4j/linalg/util/ArrayUtil.java @@ -459,7 +459,7 @@ public class ArrayUtil { * @return the sum of this array */ public static int sum(List add) { - if (add.size() < 1) + if (add.isEmpty()) return 0; int ret = 0; for (int i = 0; i < add.size(); i++) @@ -498,7 +498,7 @@ public class ArrayUtil { * @return the product of this array */ public static int prod(List mult) { - if (mult.size() < 1) + if (mult.isEmpty()) return 0; int ret = 1; for (int i = 0; i < mult.size(); i++) @@ -546,7 +546,7 @@ public class ArrayUtil { * @return the product of this array */ public static long prodLong(List mult) { - if (mult.size() < 1) + if (mult.isEmpty()) return 0; long ret = 1; for (int i = 0; i < mult.size(); i++) @@ -1383,7 +1383,7 @@ public class ArrayUtil { long[] oldShapeB; - if (listB.size() == 0) { + if (listB.isEmpty()) { oldShapeB = new long[] {1}; } else { oldShapeB = Longs.toArray(listB); @@ -2965,7 +2965,7 @@ public class ArrayUtil { // now all even elements will be interleaved with odd elements for (int i = 0; i < result.length; i++) { - if (i % 2 == 0 && indexes.size() >= 1) { + if (i % 2 == 0 && !indexes.isEmpty()) { int idx = indexes.get(0); indexes.remove(0); result[i] = idx; @@ -3004,7 +3004,7 @@ public class ArrayUtil { // now all even elements will be interleaved with odd elements for (int i = 0; i < result.length; i++) { - if (i % 2 == 0 && indexes.size() >= 1) { + if (i % 2 == 0 && !indexes.isEmpty()) { int idx = indexes.get(0); indexes.remove(0); result[i] = idx; @@ -3132,7 +3132,7 @@ public class ArrayUtil { public static T getRandomElement(List list) { - if (list.size() < 1) + if (list.isEmpty()) return null; return list.get(RandomUtils.nextInt(0, list.size())); diff --git a/nd4j/nd4j-common/src/main/java/org/nd4j/linalg/util/MathUtils.java b/nd4j/nd4j-common/src/main/java/org/nd4j/linalg/util/MathUtils.java index c32b43669..51ef18253 100644 --- a/nd4j/nd4j-common/src/main/java/org/nd4j/linalg/util/MathUtils.java +++ b/nd4j/nd4j-common/src/main/java/org/nd4j/linalg/util/MathUtils.java @@ -1326,11 +1326,11 @@ public class MathUtils { public static float randomFloatBetween(float begin, float end) { float rand = (float) Math.random(); - return begin + (rand * ((end - begin))); + return begin + (rand * (end - begin)); } public static double randomDoubleBetween(double begin, double end) { - return begin + (Math.random() * ((end - begin))); + return begin + (Math.random() * (end - begin)); } /** diff --git a/nd4j/nd4j-jdbc/nd4j-jdbc-api/src/main/java/org/nd4j/jdbc/driverfinder/DriverFinder.java b/nd4j/nd4j-jdbc/nd4j-jdbc-api/src/main/java/org/nd4j/jdbc/driverfinder/DriverFinder.java index e467035e8..4fa9cc794 100644 --- a/nd4j/nd4j-jdbc/nd4j-jdbc-api/src/main/java/org/nd4j/jdbc/driverfinder/DriverFinder.java +++ b/nd4j/nd4j-jdbc/nd4j-jdbc-api/src/main/java/org/nd4j/jdbc/driverfinder/DriverFinder.java @@ -16,6 +16,8 @@ package org.nd4j.jdbc.driverfinder; +import lombok.extern.slf4j.Slf4j; + import java.io.IOException; import java.io.InputStream; import java.sql.Driver; @@ -29,6 +31,7 @@ import java.util.Set; * * @author Adam Gibson */ +@Slf4j public class DriverFinder { public final static String ND4j_JDBC_PROPERTIES = "nd4j.jdbc.properties"; @@ -43,9 +46,9 @@ public class DriverFinder { try { driver = clazz.newInstance(); } catch (InstantiationException e) { - e.printStackTrace(); + log.error("",e); } catch (IllegalAccessException e) { - e.printStackTrace(); + log.error("",e); } } return driver; diff --git a/nd4j/nd4j-jdbc/nd4j-jdbc-hsql/src/test/java/org/nd4j/jdbc/hsql/HSqlLoaderTest.java b/nd4j/nd4j-jdbc/nd4j-jdbc-hsql/src/test/java/org/nd4j/jdbc/hsql/HSqlLoaderTest.java index e4340c3a6..a546e8da9 100644 --- a/nd4j/nd4j-jdbc/nd4j-jdbc-hsql/src/test/java/org/nd4j/jdbc/hsql/HSqlLoaderTest.java +++ b/nd4j/nd4j-jdbc/nd4j-jdbc-hsql/src/test/java/org/nd4j/jdbc/hsql/HSqlLoaderTest.java @@ -16,6 +16,7 @@ package org.nd4j.jdbc.hsql; +import lombok.extern.slf4j.Slf4j; import org.hsqldb.jdbc.JDBCDataSource; import org.junit.AfterClass; import org.junit.BeforeClass; @@ -32,6 +33,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat; +@Slf4j public class HSqlLoaderTest extends BaseND4JTest { private static HsqlLoader hsqlLoader; private static DataSource dataSource; @@ -114,7 +116,7 @@ public class HSqlLoaderTest extends BaseND4JTest { return result.getInt("total"); } } catch (SQLException e) { - e.printStackTrace(); + log.error("",e); } return 0; } diff --git a/nd4j/nd4j-parameter-server-parent/nd4j-parameter-server-client/src/main/java/org/nd4j/parameterserver/client/ParameterServerClient.java b/nd4j/nd4j-parameter-server-parent/nd4j-parameter-server-client/src/main/java/org/nd4j/parameterserver/client/ParameterServerClient.java index b41e0389c..d962bbfcf 100644 --- a/nd4j/nd4j-parameter-server-parent/nd4j-parameter-server-client/src/main/java/org/nd4j/parameterserver/client/ParameterServerClient.java +++ b/nd4j/nd4j-parameter-server-parent/nd4j-parameter-server-client/src/main/java/org/nd4j/parameterserver/client/ParameterServerClient.java @@ -96,7 +96,7 @@ public class ParameterServerClient implements NDArrayCallback { .asJson().getBody().toString(), MasterStatus.class).getResponderN(); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); } return 0; } @@ -135,7 +135,7 @@ public class ParameterServerClient implements NDArrayCallback { .asJson().getBody().toString(), SubscriberState.class); return subscriberState.isReady(); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); } return false; } @@ -163,7 +163,7 @@ public class ParameterServerClient implements NDArrayCallback { .asJson().getBody().toString(), MasterStatus.class).started(); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); } return false; } diff --git a/nd4j/nd4j-parameter-server-parent/nd4j-parameter-server-client/src/test/java/org/nd4j/parameterserver/background/BackgroundDaemonStarter.java b/nd4j/nd4j-parameter-server-parent/nd4j-parameter-server-client/src/test/java/org/nd4j/parameterserver/background/BackgroundDaemonStarter.java index aa32ba514..6fd33fe75 100644 --- a/nd4j/nd4j-parameter-server-parent/nd4j-parameter-server-client/src/test/java/org/nd4j/parameterserver/background/BackgroundDaemonStarter.java +++ b/nd4j/nd4j-parameter-server-parent/nd4j-parameter-server-client/src/test/java/org/nd4j/parameterserver/background/BackgroundDaemonStarter.java @@ -123,7 +123,7 @@ public class BackgroundDaemonStarter { .redirectOutput(System.out).destroyOnExit().redirectError(System.err).execute() .getExitValue(); } catch (TimeoutException e) { - e.printStackTrace(); + log.error("",e); } } else { List args2 = new ArrayList<>( @@ -133,7 +133,7 @@ public class BackgroundDaemonStarter { new ProcessExecutor().command(args2).destroyOnExit().readOutput(true).redirectOutput(System.out) .redirectError(System.err).execute().getExitValue(); } catch (TimeoutException e) { - e.printStackTrace(); + log.error("",e); } } diff --git a/nd4j/nd4j-parameter-server-parent/nd4j-parameter-server-client/src/test/java/org/nd4j/parameterserver/background/RemoteParameterServerClientTests.java b/nd4j/nd4j-parameter-server-parent/nd4j-parameter-server-client/src/test/java/org/nd4j/parameterserver/background/RemoteParameterServerClientTests.java index 6398cbab1..d94b1384a 100644 --- a/nd4j/nd4j-parameter-server-parent/nd4j-parameter-server-client/src/test/java/org/nd4j/parameterserver/background/RemoteParameterServerClientTests.java +++ b/nd4j/nd4j-parameter-server-parent/nd4j-parameter-server-client/src/test/java/org/nd4j/parameterserver/background/RemoteParameterServerClientTests.java @@ -63,7 +63,7 @@ public class RemoteParameterServerClientTests extends BaseND4JTest { masterStatus.set( BackgroundDaemonStarter.startMaster(parameterLength, mediaDriver.aeronDirectoryName())); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); } }); @@ -73,7 +73,7 @@ public class RemoteParameterServerClientTests extends BaseND4JTest { try { slaveStatus.set(BackgroundDaemonStarter.startSlave(parameterLength, mediaDriver.aeronDirectoryName())); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); } }); t2.start(); diff --git a/nd4j/nd4j-parameter-server-parent/nd4j-parameter-server-node/src/main/java/org/nd4j/parameterserver/distributed/messages/intercom/DistributedAssignMessage.java b/nd4j/nd4j-parameter-server-parent/nd4j-parameter-server-node/src/main/java/org/nd4j/parameterserver/distributed/messages/intercom/DistributedAssignMessage.java index 6a96fcc45..1a4942f18 100644 --- a/nd4j/nd4j-parameter-server-parent/nd4j-parameter-server-node/src/main/java/org/nd4j/parameterserver/distributed/messages/intercom/DistributedAssignMessage.java +++ b/nd4j/nd4j-parameter-server-parent/nd4j-parameter-server-node/src/main/java/org/nd4j/parameterserver/distributed/messages/intercom/DistributedAssignMessage.java @@ -20,7 +20,6 @@ import lombok.*; import org.nd4j.linalg.api.ndarray.INDArray; import org.nd4j.parameterserver.distributed.messages.BaseVoidMessage; import org.nd4j.parameterserver.distributed.messages.DistributedMessage; -import org.nd4j.parameterserver.distributed.messages.RequestMessage; /** * Assign target row to specified value diff --git a/nd4j/nd4j-parameter-server-parent/nd4j-parameter-server-node/src/main/java/org/nd4j/parameterserver/distributed/v2/chunks/impl/FileChunksTracker.java b/nd4j/nd4j-parameter-server-parent/nd4j-parameter-server-node/src/main/java/org/nd4j/parameterserver/distributed/v2/chunks/impl/FileChunksTracker.java index fc19e271f..9b37d9bb9 100644 --- a/nd4j/nd4j-parameter-server-parent/nd4j-parameter-server-node/src/main/java/org/nd4j/parameterserver/distributed/v2/chunks/impl/FileChunksTracker.java +++ b/nd4j/nd4j-parameter-server-parent/nd4j-parameter-server-node/src/main/java/org/nd4j/parameterserver/distributed/v2/chunks/impl/FileChunksTracker.java @@ -18,6 +18,7 @@ package org.nd4j.parameterserver.distributed.v2.chunks.impl; import lombok.Getter; import lombok.NonNull; +import lombok.extern.slf4j.Slf4j; import lombok.val; import org.nd4j.linalg.exception.ND4JIllegalStateException; import org.nd4j.linalg.primitives.AtomicBoolean; @@ -34,6 +35,7 @@ import java.util.concurrent.ConcurrentHashMap; /** * File-based implementation of ChunksTracker */ +@Slf4j public class FileChunksTracker implements ChunksTracker { @Getter private final String originId; @@ -114,7 +116,7 @@ public class FileChunksTracker implements ChunksTracker print the usage info jcmdr.usage(); try { diff --git a/nd4j/nd4j-remote/nd4j-json-client/src/main/java/org/nd4j/remote/clients/serde/impl/DoubleArraySerde.java b/nd4j/nd4j-remote/nd4j-json-client/src/main/java/org/nd4j/remote/clients/serde/impl/DoubleArraySerde.java index fbe44a101..3ada3fc08 100644 --- a/nd4j/nd4j-remote/nd4j-json-client/src/main/java/org/nd4j/remote/clients/serde/impl/DoubleArraySerde.java +++ b/nd4j/nd4j-remote/nd4j-json-client/src/main/java/org/nd4j/remote/clients/serde/impl/DoubleArraySerde.java @@ -17,13 +17,6 @@ package org.nd4j.remote.clients.serde.impl; import lombok.*; -import org.nd4j.remote.clients.serde.JsonDeserializer; -import org.nd4j.remote.clients.serde.JsonSerializer; -import org.nd4j.shade.jackson.core.JsonProcessingException; -import org.nd4j.shade.jackson.databind.ObjectMapper; - -import java.io.IOException; - /** * This class provides JSON ser/de for Java double[] */ diff --git a/nd4j/nd4j-serde/nd4j-aeron/src/main/java/org/nd4j/aeron/ipc/AeronNDArraySubscriber.java b/nd4j/nd4j-serde/nd4j-aeron/src/main/java/org/nd4j/aeron/ipc/AeronNDArraySubscriber.java index f5786b9e9..04cb3a880 100644 --- a/nd4j/nd4j-serde/nd4j-aeron/src/main/java/org/nd4j/aeron/ipc/AeronNDArraySubscriber.java +++ b/nd4j/nd4j-serde/nd4j-aeron/src/main/java/org/nd4j/aeron/ipc/AeronNDArraySubscriber.java @@ -174,7 +174,7 @@ public class AeronNDArraySubscriber implements AutoCloseable { try { subscriber.launch(); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); } }); @@ -206,7 +206,7 @@ public class AeronNDArraySubscriber implements AutoCloseable { try { subscriber.launch(); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); } }); diff --git a/nd4j/nd4j-serde/nd4j-aeron/src/main/java/org/nd4j/aeron/ipc/response/AeronNDArrayResponder.java b/nd4j/nd4j-serde/nd4j-aeron/src/main/java/org/nd4j/aeron/ipc/response/AeronNDArrayResponder.java index 482b269a5..ff9e826ba 100644 --- a/nd4j/nd4j-serde/nd4j-aeron/src/main/java/org/nd4j/aeron/ipc/response/AeronNDArrayResponder.java +++ b/nd4j/nd4j-serde/nd4j-aeron/src/main/java/org/nd4j/aeron/ipc/response/AeronNDArrayResponder.java @@ -172,7 +172,7 @@ public class AeronNDArrayResponder implements AutoCloseable { try { subscriber.launch(); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); } }); @@ -210,7 +210,7 @@ public class AeronNDArrayResponder implements AutoCloseable { try { subscriber.launch(); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); } }); diff --git a/nd4j/nd4j-serde/nd4j-aeron/src/main/java/org/nd4j/aeron/ipc/response/NDArrayResponseFragmentHandler.java b/nd4j/nd4j-serde/nd4j-aeron/src/main/java/org/nd4j/aeron/ipc/response/NDArrayResponseFragmentHandler.java index d259530a0..f42bfe9f4 100644 --- a/nd4j/nd4j-serde/nd4j-aeron/src/main/java/org/nd4j/aeron/ipc/response/NDArrayResponseFragmentHandler.java +++ b/nd4j/nd4j-serde/nd4j-aeron/src/main/java/org/nd4j/aeron/ipc/response/NDArrayResponseFragmentHandler.java @@ -21,6 +21,7 @@ import io.aeron.logbuffer.FragmentHandler; import io.aeron.logbuffer.Header; import lombok.AllArgsConstructor; import lombok.Builder; +import lombok.extern.slf4j.Slf4j; import org.agrona.DirectBuffer; import org.nd4j.aeron.ipc.AeronNDArrayPublisher; import org.nd4j.aeron.ipc.AeronUtil; @@ -42,6 +43,7 @@ import java.nio.ByteOrder; */ @AllArgsConstructor @Builder +@Slf4j public class NDArrayResponseFragmentHandler implements FragmentHandler { private NDArrayHolder holder; private Aeron.Context context; @@ -80,13 +82,13 @@ public class NDArrayResponseFragmentHandler implements FragmentHandler { try { publisher.publish(arrGet); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); } try { publisher.close(); } catch (Exception e) { - + log.error("",e); } } } diff --git a/nd4j/nd4j-serde/nd4j-aeron/src/test/java/org/nd4j/aeron/ipc/LargeNdArrayIpcTest.java b/nd4j/nd4j-serde/nd4j-aeron/src/test/java/org/nd4j/aeron/ipc/LargeNdArrayIpcTest.java index bd3ac9b9c..bb572a348 100644 --- a/nd4j/nd4j-serde/nd4j-aeron/src/test/java/org/nd4j/aeron/ipc/LargeNdArrayIpcTest.java +++ b/nd4j/nd4j-serde/nd4j-aeron/src/test/java/org/nd4j/aeron/ipc/LargeNdArrayIpcTest.java @@ -110,7 +110,7 @@ public class LargeNdArrayIpcTest extends BaseND4JTest { try { subscriber.launch(); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); } }); diff --git a/nd4j/nd4j-serde/nd4j-aeron/src/test/java/org/nd4j/aeron/ipc/NdArrayIpcTest.java b/nd4j/nd4j-serde/nd4j-aeron/src/test/java/org/nd4j/aeron/ipc/NdArrayIpcTest.java index d1a95ffde..ad8b8c16e 100644 --- a/nd4j/nd4j-serde/nd4j-aeron/src/test/java/org/nd4j/aeron/ipc/NdArrayIpcTest.java +++ b/nd4j/nd4j-serde/nd4j-aeron/src/test/java/org/nd4j/aeron/ipc/NdArrayIpcTest.java @@ -109,7 +109,7 @@ public class NdArrayIpcTest extends BaseND4JTest { try { subscriber.launch(); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); } }); @@ -133,7 +133,7 @@ public class NdArrayIpcTest extends BaseND4JTest { publisher.publish(arr); log.info("Sent array"); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); } }); @@ -189,7 +189,7 @@ public class NdArrayIpcTest extends BaseND4JTest { try { subscriber.launch(); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); } }); diff --git a/nd4j/nd4j-tensorflow/src/main/java/org/nd4j/tensorflow/conversion/graphrunner/GraphRunner.java b/nd4j/nd4j-tensorflow/src/main/java/org/nd4j/tensorflow/conversion/graphrunner/GraphRunner.java index 49861e3fe..f3cc72135 100644 --- a/nd4j/nd4j-tensorflow/src/main/java/org/nd4j/tensorflow/conversion/graphrunner/GraphRunner.java +++ b/nd4j/nd4j-tensorflow/src/main/java/org/nd4j/tensorflow/conversion/graphrunner/GraphRunner.java @@ -540,7 +540,7 @@ public class GraphRunner implements Closeable { org.tensorflow.framework.GraphDef graphDef1 = org.tensorflow.framework.GraphDef.parseFrom(graphToUse); initSessionAndStatusIfNeeded(graphDef1); } catch (org.nd4j.shade.protobuf.InvalidProtocolBufferException e) { - e.printStackTrace(); + log.error("",e); } } @@ -562,7 +562,7 @@ public class GraphRunner implements Closeable { org.tensorflow.framework.ConfigProto configProto = org.tensorflow.framework.ConfigProto.parseFrom(binaryString); return configProto; } catch (Exception e) { - e.printStackTrace(); + log.error("",e); } return null; @@ -641,7 +641,7 @@ public class GraphRunner implements Closeable { try { return org.nd4j.shade.protobuf.util.JsonFormat.printer().print(sessionOptionsConfigProto); } catch (Exception e) { - e.printStackTrace(); + log.error("",e); } return null; @@ -681,7 +681,7 @@ public class GraphRunner implements Closeable { } } catch (Exception e) { - e.printStackTrace(); + log.error("",e); } return builder1.build();