Class BaseSpatialPadding2D<T extends Tensor<T>>

java.lang.Object
deepboof.BaseTensor
deepboof.impl.forward.standard.BaseSpatialPadding2D<T>
All Implemented Interfaces:
SpatialPadding2D<T>, ITensor, VTensor
Direct Known Subclasses:
SpatialPadding2D_F32, SpatialPadding2D_F64

public abstract class BaseSpatialPadding2D<T extends Tensor<T>>
extends BaseTensor
implements SpatialPadding2D<T>
Abstract class fo all virtual 2D spatial padding implementation. Virtual padding contains a reference to the original input tensor which is going to be padded and on the fly will generate the values for elements which are not explicitly contained in the input tensor. This can reduce memory consumption and is more simplistic to implement for more complex padding methods.
  • Field Details

    • config

      protected ConfigPadding config
    • input

      protected T extends Tensor<T> input
    • ROW0

      protected int ROW0
    • ROW1

      protected int ROW1
    • COL0

      protected int COL0
    • COL1

      protected int COL1
  • Constructor Details

    • BaseSpatialPadding2D

      public BaseSpatialPadding2D​(ConfigPadding config)
  • Method Details

    • setInput

      public void setInput​(T input)
      Spatial tensor that padding is being added around
      Specified by:
      setInput in interface SpatialPadding2D<T extends Tensor<T>>
      Parameters:
      input - The input tensor
    • getPaddingRow0

      public int getPaddingRow0()
      Returns the lower-extent padding along the tensor's rows.
      Specified by:
      getPaddingRow0 in interface SpatialPadding2D<T extends Tensor<T>>
      Returns:
      padding
    • getPaddingCol0

      public int getPaddingCol0()
      Returns the lower-extent padding along the tensor's columns.
      Specified by:
      getPaddingCol0 in interface SpatialPadding2D<T extends Tensor<T>>
      Returns:
      padding
    • getPaddingRow1

      public int getPaddingRow1()
      Returns the upper-extent padding along the tensor's rows.
      Specified by:
      getPaddingRow1 in interface SpatialPadding2D<T extends Tensor<T>>
      Returns:
      padding
    • getPaddingCol1

      public int getPaddingCol1()
      Returns the upper-extent padding along the tensor's columns.
      Specified by:
      getPaddingCol1 in interface SpatialPadding2D<T extends Tensor<T>>
      Returns:
      padding
    • shapeGivenInput

      public int[] shapeGivenInput​(int... inputShape)
      Returns what the tensor's shape will be when given can input tensor with the spcified shape.
      Specified by:
      shapeGivenInput in interface SpatialPadding2D<T extends Tensor<T>>
      Parameters:
      inputShape - Input spatial tensor. 3-DOF with no mini-batch or 4-DOF with mini-batch
      Returns:
      Tensor's shape
    • checkBackwardsShapeChannel

      public <T extends Tensor<T>> void checkBackwardsShapeChannel​(Tensor<T> padded, Tensor<T> original)
      Sanity checks the input for backwards images
      Parameters:
      padded - Input padded single channel image from forward layer
      original - Output backwards spatial tensor
    • checkBackwardsShapeImage

      public <T extends Tensor<T>> void checkBackwardsShapeImage​(Tensor<T> padded, Tensor<T> original)
      Sanity checks the input for backwards images
      Parameters:
      padded - Input padded image from forward layer
      original - Output backwards spatial tensor