BaseSpatialPadding2D extends BaseTensor implements SpatialPadding2D<T> { @Override public int[] shapeGivenInput( int ...inputShape ) { if( inputShape.length == 3) return new int[]{ inputShape[0], inputShape[1]+config.y0 +config.y1, inputShape[2]+config.x0 +config.x1, }; else if( inputShape.length == 4 ) { return new int[]{ inputShape[0], inputShape[1], inputShape[2]+config.y0 +config.y1, inputShape[3]+config.x0 +config.x1, }; } else { throw new IllegalArgumentException("Spatial tensor with 3 or 4 dof expected"); } } BaseSpatialPadding2D(ConfigPadding config); void setInput(T input); @Override int getPaddingRow0(); @Override int getPaddingCol0(); @Override int getPaddingRow1(); @Override int getPaddingCol1(); @Override int[] shapeGivenInput( int ...inputShape ); void checkBackwardsShapeChannel( Tensor<T> padded , Tensor<T> original ); void checkBackwardsShapeImage( Tensor<T> padded , Tensor<T> original );  }
@Test public void shapeGivenInput() { Helper alg = new Helper(config); int found[] = alg.shapeGivenInput(new int[]{2,9,10}); DeepUnitTest.assertEquals(new int[]{2,15,14},found); found = alg.shapeGivenInput(new int[]{5,2,9,10}); DeepUnitTest.assertEquals(new int[]{5,2,15,14},found); }