From 3fb9aecb59f437f9d2a5f4ac7b34b7773123bb49 Mon Sep 17 00:00:00 2001 From: Alex Black Date: Tue, 10 Sep 2019 12:22:10 +1000 Subject: [PATCH] Fix for null shape in SameDiff.var validation (#250) Signed-off-by: AlexDBlack --- .../src/main/java/org/nd4j/autodiff/samediff/SameDiff.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/SameDiff.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/SameDiff.java index 955677ca8..452077238 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/SameDiff.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/SameDiff.java @@ -3367,8 +3367,10 @@ public class SameDiff extends SDBaseOps { */ public SDVariable var(@NonNull String name, @NonNull VariableType variableType, WeightInitScheme weightInitScheme, org.nd4j.linalg.api.buffer.DataType dataType, long... shape) { - for(long l : shape){ - Preconditions.checkArgument(l != 0, "Cannot create variable with a shape that contains zeros (empty array shape) - got shape %s", shape); + if(shape != null) { + for (long l : shape) { + Preconditions.checkArgument(l != 0, "Cannot create variable with a shape that contains zeros (empty array shape) - got shape %s", shape); + } } if (name == null || name.length() < 1)