Small fixes. (#206)

* Logging format tweaks for file logging

Signed-off-by: AlexDBlack <blacka101@gmail.com>

* Min abs error tweak for Util layer gradient checks

Signed-off-by: AlexDBlack <blacka101@gmail.com>

* #8648 Fix SameDiff NPE instead of error for missing placeholders

Signed-off-by: AlexDBlack <blacka101@gmail.com>

* Test runtime reduction

Signed-off-by: AlexDBlack <blacka101@gmail.com>
master
Alex Black 2020-02-01 18:19:36 +11:00 committed by GitHub
parent d52e67209e
commit 0756e3fe70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 82 additions and 77 deletions

View File

@ -43,12 +43,6 @@ import java.util.Random;
public class CapsnetGradientCheckTest extends BaseDL4JTest {
private static final boolean PRINT_RESULTS = true;
private static final boolean RETURN_ON_FIRST_FAILURE = false;
private static final double DEFAULT_EPS = 1e-6;
private static final double DEFAULT_MAX_REL_ERROR = 1e-3;
private static final double DEFAULT_MIN_ABS_ERROR = 1e-8;
@Test
public void testCapsNet() {

View File

@ -43,10 +43,6 @@ import static org.junit.Assert.assertTrue;
public class OutputLayerGradientChecks extends BaseDL4JTest {
private static final boolean PRINT_RESULTS = true;
private static final boolean RETURN_ON_FIRST_FAILURE = false;
private static final double DEFAULT_EPS = 1e-6;
private static final double DEFAULT_MAX_REL_ERROR = 1e-3;
private static final double DEFAULT_MIN_ABS_ERROR = 1e-8;
static {
Nd4j.setDataType(DataType.DOUBLE);

View File

@ -47,10 +47,6 @@ import static org.junit.Assert.assertTrue;
public class RnnGradientChecks extends BaseDL4JTest {
private static final boolean PRINT_RESULTS = true;
private static final boolean RETURN_ON_FIRST_FAILURE = false;
private static final double DEFAULT_EPS = 1e-6;
private static final double DEFAULT_MAX_REL_ERROR = 1e-3;
private static final double DEFAULT_MIN_ABS_ERROR = 1e-8;
static {
Nd4j.setDataType(DataType.DOUBLE);

View File

@ -48,12 +48,6 @@ import static org.junit.Assert.assertTrue;
public class UtilLayerGradientChecks extends BaseDL4JTest {
private static final boolean PRINT_RESULTS = true;
private static final boolean RETURN_ON_FIRST_FAILURE = false;
private static final double DEFAULT_EPS = 1e-6;
private static final double DEFAULT_MAX_REL_ERROR = 1e-3;
private static final double DEFAULT_MIN_ABS_ERROR = 1e-6;
static {
Nd4j.setDataType(DataType.DOUBLE);
}
@ -182,9 +176,9 @@ public class UtilLayerGradientChecks extends BaseDL4JTest {
MultiLayerNetwork net = new MultiLayerNetwork(conf);
net.init();
boolean gradOK = GradientCheckUtil.checkGradients(new GradientCheckUtil.MLNConfig().net(net).input(input)
.minAbsoluteError(1e-7)
.labels(label).inputMask(inMask));
boolean gradOK = GradientCheckUtil.checkGradients(new GradientCheckUtil.MLNConfig().net(net)
.minAbsoluteError(1e-6)
.input(input).labels(label).inputMask(inMask));
assertTrue(gradOK);
TestUtils.testModelSerialization(net);
@ -233,8 +227,9 @@ public class UtilLayerGradientChecks extends BaseDL4JTest {
//Test ComputationGraph equivalent:
ComputationGraph g = net.toComputationGraph();
boolean gradOKCG = GradientCheckUtil.checkGradients(new GradientCheckUtil.GraphConfig().net(g).inputs(new INDArray[]{in})
.labels(new INDArray[]{labels}).excludeParams(excludeParams));
boolean gradOKCG = GradientCheckUtil.checkGradients(new GradientCheckUtil.GraphConfig().net(g)
.minAbsoluteError(1e-6)
.inputs(new INDArray[]{in}).labels(new INDArray[]{labels}).excludeParams(excludeParams));
assertTrue(gradOKCG);
TestUtils.testModelSerialization(g);

View File

@ -56,11 +56,6 @@ import static org.junit.Assert.assertTrue;
* @author Alex Black
*/
public class YoloGradientCheckTests extends BaseDL4JTest {
private static final boolean PRINT_RESULTS = true;
private static final boolean RETURN_ON_FIRST_FAILURE = false;
private static final double DEFAULT_EPS = 1e-6;
private static final double DEFAULT_MAX_REL_ERROR = 1e-3;
private static final double DEFAULT_MIN_ABS_ERROR = 1e-8;
static {
Nd4j.setDataType(DataType.DOUBLE);

View File

@ -19,8 +19,8 @@
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>logs/application.log</file>
<encoder>
<pattern>%date - [%level] - from %logger in %thread
%n%message%n%xException%n</pattern>
<pattern> %logger{15} - %message%n%xException{5}
</pattern>
</encoder>
</appender>

View File

@ -19,8 +19,8 @@
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>logs/application.log</file>
<encoder>
<pattern>%date - [%level] - from %logger in %thread
%n%message%n%xException%n</pattern>
<pattern> %logger{15} - %message%n%xException{5}
</pattern>
</encoder>
</appender>

View File

@ -19,8 +19,8 @@
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>logs/application.log</file>
<encoder>
<pattern>%date - [%level] - from %logger in %thread
%n%message%n%xException%n</pattern>
<pattern> %logger{15} - %message%n%xException{5}
</pattern>
</encoder>
</appender>

View File

@ -21,8 +21,8 @@
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>logs/application.log</file>
<encoder>
<pattern>%date - [%level] - from %logger in %thread
%n%message%n%xException%n</pattern>
<pattern> %logger{15} - %message%n%xException{5}
</pattern>
</encoder>
</appender>

View File

@ -21,8 +21,8 @@
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>logs/application.log</file>
<encoder>
<pattern>%date - [%level] - from %logger in %thread
%n%message%n%xException%n</pattern>
<pattern> %logger{15} - %message%n%xException{5}
</pattern>
</encoder>
</appender>

View File

@ -21,8 +21,8 @@
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>logs/application.log</file>
<encoder>
<pattern>%date - [%level] - from %logger in %thread
%n%message%n%xException%n</pattern>
<pattern> %logger{15} - %message%n%xException{5}
</pattern>
</encoder>
</appender>

View File

@ -21,8 +21,8 @@
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>logs/application.log</file>
<encoder>
<pattern>%date - [%level] - from %logger in %thread
%n%message%n%xException%n</pattern>
<pattern> %logger{15} - %message%n%xException{5}
</pattern>
</encoder>
</appender>

View File

@ -21,8 +21,8 @@
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>logs/application.log</file>
<encoder>
<pattern>%date - [%level] - from %logger in %thread
%n%message%n%xException%n</pattern>
<pattern> %logger{15} - %message%n%xException{5}
</pattern>
</encoder>
</appender>

View File

@ -21,8 +21,8 @@
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>logs/application.log</file>
<encoder>
<pattern>%date - [%level] - from %logger in %thread
%n%message%n%xException%n</pattern>
<pattern> %logger{15} - %message%n%xException{5}
</pattern>
</encoder>
</appender>

View File

@ -21,8 +21,8 @@
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>logs/application.log</file>
<encoder>
<pattern>%date - [%level] - from %logger in %thread
%n%message%n%xException%n</pattern>
<pattern> %logger{15} - %message%n%xException{5}
</pattern>
</encoder>
</appender>

View File

@ -21,8 +21,8 @@
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>logs/application.log</file>
<encoder>
<pattern>%date - [%level] - from %logger in %thread
%n%message%n%xException%n</pattern>
<pattern> %logger{15} - %message%n%xException{5}
</pattern>
</encoder>
</appender>

View File

@ -21,8 +21,8 @@
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>logs/application.log</file>
<encoder>
<pattern>%date - [%level] - from %logger in %thread
%n%message%n%xException%n</pattern>
<pattern> %logger{15} - %message%n%xException{5}
</pattern>
</encoder>
</appender>

View File

@ -21,8 +21,8 @@
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>logs/application.log</file>
<encoder>
<pattern>%date - [%level] - from %logger in %thread
%n%message%n%xException%n</pattern>
<pattern> %logger{15} - %message%n%xException{5}
</pattern>
</encoder>
</appender>

View File

@ -19,8 +19,8 @@
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>logs/application.log</file>
<encoder>
<pattern>%date - [%level] - from %logger in %thread
%n%message%n%xException%n</pattern>
<pattern> %logger{15} - %message%n%xException{5}
</pattern>
</encoder>
</appender>

View File

@ -25,6 +25,7 @@ import org.nd4j.autodiff.samediff.SDVariable;
import org.nd4j.autodiff.samediff.SameDiff;
import org.nd4j.autodiff.samediff.VariableType;
import org.nd4j.base.Preconditions;
import org.nd4j.linalg.api.ndarray.INDArray;
import org.nd4j.linalg.api.ops.impl.controlflow.compat.*;
import org.nd4j.linalg.dataset.api.MultiDataSet;
import org.nd4j.linalg.function.Predicate;
@ -295,9 +296,13 @@ public abstract class AbstractSession<T, O> {
}
} else if (es.getType() == ExecType.PLACEHOLDER) {
VarId vid = new VarId(es.getName(), OUTER_FRAME, 0, null);
nodeOutputs.put(vid, placeholderValues.get(es.getName()));
T phVal = placeholderValues == null ? null : placeholderValues.get(es.getName());
nodeOutputs.put(vid, phVal);
outFrameIter = new FrameIter(OUTER_FRAME, 0, null);
if (allRequired.contains(es.getName())) {
Preconditions.checkState(placeholderValues != null && placeholderValues.containsKey(es.getName()),
"No array was provided for the placeholder variable \"%s\" that is required for execution", es.getName());
//User requested placeholder value as one of the outputs
out.put(es.getName(), placeholderValues.get(es.getName()));
}

View File

@ -21,8 +21,8 @@
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>logs/application.log</file>
<encoder>
<pattern>%date - [%level] - from %logger in %thread
%n%message%n%xException%n</pattern>
<pattern> %logger{15} - %message%n%xException{5}
</pattern>
</encoder>
</appender>

View File

@ -38,6 +38,7 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.nd4j.OpValidationSuite;
import org.nd4j.autodiff.loss.LossReduce;
import org.nd4j.autodiff.samediff.api.OutAndGrad;
import org.nd4j.autodiff.validation.OpValidation;
import org.nd4j.autodiff.validation.TestCase;
@ -3528,4 +3529,27 @@ public class SameDiffTests extends BaseNd4jTest {
String s = out.toString();
}
}
@Test
public void testMissingPlaceholderError(){
SameDiff sd = SameDiff.create();
int nOut = 4;
int minibatch = 10;
SDVariable predictions = sd.var("in", DataType.DOUBLE, minibatch, nOut);
SDVariable labels = sd.placeHolder("labels", DataType.DOUBLE, -1, nOut);
LossReduce reduction = LossReduce.MEAN_BY_NONZERO_WEIGHT_COUNT;
SDVariable loss = sd.loss().absoluteDifference("loss", labels, predictions, null, reduction);
try {
loss.eval();
fail("Exception should have been thrown");
} catch (IllegalStateException e){
String msg = e.getMessage();
assertTrue(msg, msg.contains("\"labels\"") && msg.contains("No array was provided"));
}
}
}

View File

@ -6935,9 +6935,9 @@ public class Nd4jTestsC extends BaseNd4jTest {
val arrayY = Nd4j.create(128, 128, 'f');
val arrayZ = Nd4j.create(128, 128, 'f');
int iterations = 10000;
int iterations = 100;
// warmup
for (int e = 0; e < 1000; e++)
for (int e = 0; e < 10; e++)
arrayX.addi(arrayY);
for (int e = 0; e < iterations; e++) {

View File

@ -21,8 +21,8 @@
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>logs/application.log</file>
<encoder>
<pattern>%date - [%level] - from %logger in %thread
%n%message%n%xException%n</pattern>
<pattern> %logger{15} - %message%n%xException{5}
</pattern>
</encoder>
</appender>

View File

@ -21,8 +21,8 @@
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>logs/application.log</file>
<encoder>
<pattern>%date - [%level] - from %logger in %thread
%n%message%n%xException%n</pattern>
<pattern> %logger{15} - %message%n%xException{5}
</pattern>
</encoder>
</appender>

View File

@ -21,8 +21,8 @@
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>logs/application.log</file>
<encoder>
<pattern>%date - [%level] - from %logger in %thread
%n%message%n%xException%n</pattern>
<pattern> %logger{15} - %message%n%xException{5}
</pattern>
</encoder>
</appender>

View File

@ -21,8 +21,8 @@
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>logs/application.log</file>
<encoder>
<pattern>%date - [%level] - from %logger in %thread
%n%message%n%xException%n</pattern>
<pattern> %logger{15} - %message%n%xException{5}
</pattern>
</encoder>
</appender>

View File

@ -21,8 +21,8 @@
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>logs/application.log</file>
<encoder>
<pattern>%date - [%level] - from %logger in %thread
%n%message%n%xException%n</pattern>
<pattern> %logger{15} - %message%n%xException{5}
</pattern>
</encoder>
</appender>

View File

@ -21,8 +21,8 @@
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>logs/application.log</file>
<encoder>
<pattern>%date - [%level] - from %logger in %thread
%n%message%n%xException%n</pattern>
<pattern> %logger{15} - %message%n%xException{5}
</pattern>
</encoder>
</appender>

View File

@ -21,8 +21,8 @@
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>logs/application.log</file>
<encoder>
<pattern>%date - [%level] - from %logger in %thread
%n%message%n%xException%n</pattern>
<pattern> %logger{15} - %message%n%xException{5}
</pattern>
</encoder>
</appender>