// note precision is off on this test but the numbers are close // investigation in a future release should determine how to resolve @Test public void testCalculateDeltaContained() { Layer layer = getContainedConfig(); INDArray input = getContainedData(); INDArray col = getContainedCol(); INDArray epsilon = Nd4j.ones(1, 2, 4, 4); INDArray expectedOutput = Nd4j.create( new double[] { 0.02036651, 0.02036651, 0.02036651, 0.02036651, 0.00039383, 0.00039383, 0.00039383, 0.00039383, 0.02036651, 0.02036651, 0.02036651, 0.02036651, 0.00039383, 0.00039383, 0.00039383, 0.00039383, 0.02036651, 0.02036651, 0.02036651, 0.02036651, 0.00039383, 0.00039383, 0.00039383, 0.00039383, 0.02036651, 0.02036651, 0.02036651, 0.02036651, 0.00039383, 0.00039383, 0.00039383, 0.00039383 }, new int[] {1, 2, 4, 4}); layer.setInput(input); org.deeplearning4j.nn.layers.convolution.ConvolutionLayer layer2 = (org.deeplearning4j.nn.layers.convolution.ConvolutionLayer) layer; layer2.setCol(col); INDArray delta = layer2.calculateDelta(epsilon); assertArrayEquals(expectedOutput.shape(), delta.shape()); assertEquals(expectedOutput, delta); }
@Test public void testCalculateDelta() { Layer layer = getContainedConfig(); INDArray col = getContainedCol(); INDArray expectedOutput = Nd4j.create( new double[] { -12., -12., -12., -12., -56., -56., -56., -56., -12., -12., -12., -12., -56., -56., -56., -56., -12., -12., -12., -12., -56., -56., -56., -56., -12., -12., -12., -12., -56., -56., -56., -56. }, new int[] {1, 2, 4, 4}); org.deeplearning4j.nn.layers.convolution.ConvolutionLayer layer2 = (org.deeplearning4j.nn.layers.convolution.ConvolutionLayer) layer; layer2.setCol(col); INDArray delta = layer2.calculateDelta(epsilon); assertEquals(expectedOutput.shape(), delta.shape()); assertEquals(expectedOutput, delta); }