@Test public void testConvolutional3DActivation() { final Matrix convolutionalActivation = convolutional3DLayer.feedForward(input3D); assertTrue(expectedConvolutional3DActivation.compare(convolutionalActivation, TOLERANCE)); }
@Override public Matrix feedForward(final Matrix input) { final Matrix output = matrixFactory.create(NeuralNetworkUtils.getShapeLength(outputShape), input.getColumns()); for (int n = 0; n < input.getColumns(); ++n) { final Matrix newValue = im2row(n, input).mmul(getLayerParameter().getWeightParam()); output.putColumn(n, newValue.reshape(NeuralNetworkUtils.getShapeLength(outputShape), 1)); } output.addiColumnVector(getLayerParameter().getBiasParam()); return output; }
ConvolutionalLayer extends LayerBase { @Override public Matrix feedForward(final Matrix input) { final Matrix output = matrixFactory.create(NeuralNetworkUtils.getShapeLength(outputShape), input.getColumns()); for (int n = 0; n < input.getColumns(); ++n) { final Matrix newValue = im2row(n, input).mmul(getLayerParameter().getWeightParam()); output.putColumn(n, newValue.reshape(NeuralNetworkUtils.getShapeLength(outputShape), 1)); } output.addiColumnVector(getLayerParameter().getBiasParam()); return output; } }
ConvolutionalLayer extends LayerBase { @Override public Matrix feedForward(final Matrix input) { final Matrix output = matrixFactory.create(NeuralNetworkUtils.getShapeLength(outputShape), input.getColumns()); for (int n = 0; n < input.getColumns(); ++n) { final Matrix newValue = im2row(n, input).mmul(getLayerParameter().getWeightParam()); output.putColumn(n, newValue.reshape(NeuralNetworkUtils.getShapeLength(outputShape), 1)); } output.addiColumnVector(getLayerParameter().getBiasParam()); return output; } @Inject private  ConvolutionalLayer(@Parameter(LayerIndex.class) final int index,
                             @Parameter(LayerInputShape.class) final String inputShape,
                             @Parameter(PaddingHeight.class) final int paddingHeight,
                             @Parameter(PaddingWidth.class) final int paddingWidth,
                             @Parameter(StrideHeight.class) final int strideHeight,
                             @Parameter(StrideWidth.class) final int strideWidth,
                             @Parameter(KernelHeight.class) final int kernelHeight,
                             @Parameter(KernelWidth.class) final int kernelWidth,
                             final LayerParameterInitializer layerParameterInitializer,
                             final MatrixFactory matrixFactory); }
ConvolutionalLayer extends LayerBase { @Override public Matrix feedForward(final Matrix input) { final Matrix output = matrixFactory.create(NeuralNetworkUtils.getShapeLength(outputShape), input.getColumns()); for (int n = 0; n < input.getColumns(); ++n) { final Matrix newValue = im2row(n, input).mmul(getLayerParameter().getWeightParam()); output.putColumn(n, newValue.reshape(NeuralNetworkUtils.getShapeLength(outputShape), 1)); } output.addiColumnVector(getLayerParameter().getBiasParam()); return output; } @Inject private  ConvolutionalLayer(@Parameter(LayerIndex.class) final int index,
                             @Parameter(LayerInputShape.class) final String inputShape,
                             @Parameter(PaddingHeight.class) final int paddingHeight,
                             @Parameter(PaddingWidth.class) final int paddingWidth,
                             @Parameter(StrideHeight.class) final int strideHeight,
                             @Parameter(StrideWidth.class) final int strideWidth,
                             @Parameter(KernelHeight.class) final int kernelHeight,
                             @Parameter(KernelWidth.class) final int kernelWidth,
                             final LayerParameterInitializer layerParameterInitializer,
                             final MatrixFactory matrixFactory); @Override int[] getOutputShape(); @Override boolean isLearnable(); @Override Matrix feedForward(final Matrix input); @Override Matrix backPropagate(final Matrix input, final Matrix activation, final Matrix nextError); @Override LayerParameter generateParameterGradient(final Matrix input, final Matrix error); }
ConvolutionalLayer extends LayerBase { @Override public Matrix feedForward(final Matrix input) { final Matrix output = matrixFactory.create(NeuralNetworkUtils.getShapeLength(outputShape), input.getColumns()); for (int n = 0; n < input.getColumns(); ++n) { final Matrix newValue = im2row(n, input).mmul(getLayerParameter().getWeightParam()); output.putColumn(n, newValue.reshape(NeuralNetworkUtils.getShapeLength(outputShape), 1)); } output.addiColumnVector(getLayerParameter().getBiasParam()); return output; } @Inject private  ConvolutionalLayer(@Parameter(LayerIndex.class) final int index,
                             @Parameter(LayerInputShape.class) final String inputShape,
                             @Parameter(PaddingHeight.class) final int paddingHeight,
                             @Parameter(PaddingWidth.class) final int paddingWidth,
                             @Parameter(StrideHeight.class) final int strideHeight,
                             @Parameter(StrideWidth.class) final int strideWidth,
                             @Parameter(KernelHeight.class) final int kernelHeight,
                             @Parameter(KernelWidth.class) final int kernelWidth,
                             final LayerParameterInitializer layerParameterInitializer,
                             final MatrixFactory matrixFactory); @Override int[] getOutputShape(); @Override boolean isLearnable(); @Override Matrix feedForward(final Matrix input); @Override Matrix backPropagate(final Matrix input, final Matrix activation, final Matrix nextError); @Override LayerParameter generateParameterGradient(final Matrix input, final Matrix error);  }