Erosion2D

@frozen
public struct Erosion2D<Scalar> : Layer where Scalar : TensorFlowFloatingPoint

A 2-D morphological erosion layer

This layer returns the morphogical erosion of the input tensor with the provided filters

  • The 4-D dilation filter.

    Declaration

    public var filter: Tensor<Scalar>
  • The strides of the sliding window for spatial dimensions.

    Declaration

    @noDerivative
    public let strides: (Int, Int)
  • The padding algorithm for dilation.

    Declaration

    @noDerivative
    public let padding: Padding
  • The dilation factor for spatial dimensions.

    Declaration

    @noDerivative
    public let rates: (Int, Int)
  • Creates a Erosion2D layer with the specified filter, strides, dilations and padding.

    Declaration

    public init(
      filter: Tensor<Scalar>,
      strides: (Int, Int) = (1, 1),
      rates: (Int, Int) = (1, 1),
      padding: Padding = .valid
    )

    Parameters

    filter

    The 4-D dilation filter of shape [filter height, filter width, input channel count, output channel count].

    strides

    The strides of the sliding window for spatial dimensions, i.e. (stride height, stride width).

    rates

    The dilation rates for spatial dimensions, i.e. (dilation height, dilation width).

    padding

    The padding algorithm for dilation.

  • Returns the output obtained from applying the layer to the given input.

    The output spatial dimensions are computed as:

    output height = (input height + 2 * padding height - (dilation height * (filter height - 1) + 1)) / stride height + 1

    output width = (input width + 2 * padding width - (dilation width * (filter width - 1) + 1)) / stride width + 1

    and padding sizes are determined by the padding scheme.

    Note

    Padding size equals zero when using .valid.

    Declaration

    @differentiable
    public func callAsFunction(_ input: Tensor<Scalar>) -> Tensor<Scalar>

    Parameters

    input

    The input to the layer of shape [batch size, input height, input width, input channel count].

    Return Value

    The output of shape [batch count, output height, output width, output channel count].