From 7939cf384b74394f0d150ad0f1498a1c7aaefd19 Mon Sep 17 00:00:00 2001 From: Alex Black Date: Fri, 19 Jul 2019 13:23:37 +1000 Subject: [PATCH] Misc fixes (#66) * Small fixes Signed-off-by: Alex Black * Flaky test fix Signed-off-by: Alex Black --- .../java/org/nd4j/autodiff/opvalidation/LossOpValidation.java | 2 +- .../org/nd4j/autodiff/opvalidation/ReductionOpValidation.java | 2 +- .../src/test/java/org/nd4j/linalg/serde/NumpyFormatTests.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nd4j/nd4j-backends/nd4j-tests/src/test/java/org/nd4j/autodiff/opvalidation/LossOpValidation.java b/nd4j/nd4j-backends/nd4j-tests/src/test/java/org/nd4j/autodiff/opvalidation/LossOpValidation.java index dcb28305e..78a4c6a4a 100644 --- a/nd4j/nd4j-backends/nd4j-tests/src/test/java/org/nd4j/autodiff/opvalidation/LossOpValidation.java +++ b/nd4j/nd4j-backends/nd4j-tests/src/test/java/org/nd4j/autodiff/opvalidation/LossOpValidation.java @@ -163,7 +163,7 @@ public class LossOpValidation extends BaseOpValidation { //Loss loss aka binary cross entropy loss //Labels are random bernoulli Nd4j.getExecutioner().exec(new BernoulliDistribution(labelsArr, 0.5)); - predictionsArr = Nd4j.rand(predictionsArr.shape()); + predictionsArr = Nd4j.rand(predictionsArr.shape()).muli(0.8).addi(0.1); INDArray logP = Transforms.log(predictionsArr.add(eps), true); INDArray log1p = Transforms.log(predictionsArr.rsub(1.0).add(eps), true); expOut = labelsArr.mul(logP).addi(labelsArr.rsub(1).mul(log1p)).negi(); diff --git a/nd4j/nd4j-backends/nd4j-tests/src/test/java/org/nd4j/autodiff/opvalidation/ReductionOpValidation.java b/nd4j/nd4j-backends/nd4j-tests/src/test/java/org/nd4j/autodiff/opvalidation/ReductionOpValidation.java index cc67f00d8..528b6823e 100644 --- a/nd4j/nd4j-backends/nd4j-tests/src/test/java/org/nd4j/autodiff/opvalidation/ReductionOpValidation.java +++ b/nd4j/nd4j-backends/nd4j-tests/src/test/java/org/nd4j/autodiff/opvalidation/ReductionOpValidation.java @@ -535,7 +535,7 @@ public class ReductionOpValidation extends BaseOpValidation { name = "norm1"; break; case 8: - maxRelError = 1e-4; + maxRelError = 1e-3; //Norm2 can also run into numerical precision issues reduced = sd.norm2("reduced", second, reduceDim); name = "norm2"; break; diff --git a/nd4j/nd4j-backends/nd4j-tests/src/test/java/org/nd4j/linalg/serde/NumpyFormatTests.java b/nd4j/nd4j-backends/nd4j-tests/src/test/java/org/nd4j/linalg/serde/NumpyFormatTests.java index 22cc2a753..8b3e98f2a 100644 --- a/nd4j/nd4j-backends/nd4j-tests/src/test/java/org/nd4j/linalg/serde/NumpyFormatTests.java +++ b/nd4j/nd4j-backends/nd4j-tests/src/test/java/org/nd4j/linalg/serde/NumpyFormatTests.java @@ -310,7 +310,7 @@ public class NumpyFormatTests extends BaseNd4jTest { INDArray act1 = Nd4j.createFromNpyFile(f); } - @Test + @Test(expected = IllegalArgumentException.class) public void testAbsentNumpyFile_2() throws Exception { val f = new File("c:/develop/batch-x-1.npy"); INDArray act1 = Nd4j.createFromNpyFile(f);