parent
614c687e4b
commit
8e3d569f18
|
@ -190,7 +190,7 @@ public class LayerHelperValidationUtil {
|
|||
} else {
|
||||
System.out.println("OK: " + p);
|
||||
}
|
||||
assertTrue("Gradients are not equal: " + p + " - highest relative error = " + maxRE + " > max relative error = " + t.getMaxRelError(),
|
||||
assertTrue(t.getTestName() + " - Gradients are not equal: " + p + " - highest relative error = " + maxRE + " > max relative error = " + t.getMaxRelError(),
|
||||
maxRE < t.getMaxRelError());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ public class ValidateMKLDNN extends BaseDL4JTest {
|
|||
for (ConvolutionMode cm : new ConvolutionMode[]{ConvolutionMode.Same, ConvolutionMode.Truncate}) {
|
||||
for (int[] kernel : new int[][]{{2, 2}, {2, 3}}) {
|
||||
for (int[] stride : new int[][]{{1, 1}, {2, 2}}) {
|
||||
for (PoolingType pt : new PoolingType[]{PoolingType.MAX, PoolingType.AVG}) {
|
||||
|
||||
inputSize[0] = minibatch;
|
||||
INDArray f = Nd4j.rand(DataType.FLOAT, inputSize);
|
||||
|
@ -74,6 +75,7 @@ public class ValidateMKLDNN extends BaseDL4JTest {
|
|||
.nOut(3)
|
||||
.build())
|
||||
.layer(new SubsamplingLayer.Builder()
|
||||
.poolingType(pt)
|
||||
.kernelSize(kernel)
|
||||
.stride(stride)
|
||||
.padding(0, 0)
|
||||
|
@ -94,7 +96,9 @@ public class ValidateMKLDNN extends BaseDL4JTest {
|
|||
MultiLayerNetwork netWithout = new MultiLayerNetwork(conf.clone());
|
||||
netWithout.init();
|
||||
|
||||
String name = pt + ", mb=" + minibatch + ", cm=" + cm + ", kernel=" + Arrays.toString(kernel) + ", stride=" + Arrays.toString(stride);
|
||||
LayerHelperValidationUtil.TestCase tc = LayerHelperValidationUtil.TestCase.builder()
|
||||
.testName(name)
|
||||
.allowHelpersForClasses(Arrays.<Class<?>>asList(org.deeplearning4j.nn.layers.convolution.subsampling.SubsamplingLayer.class,
|
||||
org.deeplearning4j.nn.layers.convolution.ConvolutionLayer.class))
|
||||
.testForward(true)
|
||||
|
@ -106,12 +110,14 @@ public class ValidateMKLDNN extends BaseDL4JTest {
|
|||
.data(new SingletonDataSetIterator(new DataSet(f, l)))
|
||||
.build();
|
||||
|
||||
System.out.println("Starting test: " + name);
|
||||
LayerHelperValidationUtil.validateMLN(netWith, tc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void validateBatchNorm() {
|
||||
|
|
|
@ -289,8 +289,14 @@ public class SubsamplingLayer extends AbstractLayer<org.deeplearning4j.nn.conf.l
|
|||
b = DynamicCustomOp.builder("maxpool2d");
|
||||
break;
|
||||
case AVG:
|
||||
b = DynamicCustomOp.builder("maxpool2d");
|
||||
extra = 1; //Divide by kH*kW not "number present" to match backward pass -- TODO change this to support both legacy behaviour (deserialized nets) and "exclude" by default for new nets
|
||||
b = DynamicCustomOp.builder("avgpool2d");
|
||||
if(layerConf().isAvgPoolIncludePadInDivisor()){
|
||||
//Mostly this is a legacy case - beta4 and earlier models.
|
||||
extra = 1; //Divide by "number present" excluding padding
|
||||
} else {
|
||||
//Default behaviour
|
||||
extra = 0; //Divide by kH*kW not "number present"
|
||||
}
|
||||
break;
|
||||
case PNORM:
|
||||
b = DynamicCustomOp.builder("pnormpool2d");
|
||||
|
|
Loading…
Reference in New Issue