DepthwiseConv2D

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

A 2-D depthwise convolution layer.

This layer creates seperable convolution filters that are convolved with the layer input to produce a tensor of outputs.

  • The 4-D convolution kernel.

    Declaration

    public var filter: Tensor<Scalar>
  • The bias vector.

    Declaration

    public var bias: Tensor<Scalar>
  • The element-wise activation function.

    Declaration

    @noDerivative
    public let activation: Activation
  • The strides of the sliding window for spatial dimensions.

    Declaration

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

    Declaration

    @noDerivative
    public let padding: Padding
  • The element-wise activation function type.

    Declaration

    public typealias Activation = @differentiable (Tensor<Scalar>) -> Tensor<Scalar>
  • Creates a DepthwiseConv2D layer with the specified filter, bias, activation function, strides, and padding.

    Declaration

    public init(
      filter: Tensor<Scalar>,
      bias: Tensor<Scalar>? = nil,
      activation: @escaping Activation = identity,
      strides: (Int, Int) = (1, 1),
      padding: Padding = .valid
    )

    Parameters

    filter

    The 4-D convolution kernel.

    bias

    The bias vector.

    activation

    The element-wise activation function.

    strides

    The strides of the sliding window for spatial dimensions.

    padding

    The padding algorithm for convolution.

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

    Declaration

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

    Parameters

    input

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

    Return Value

    The output of shape, [batch count, output height, output width, input channel count * channel multiplier]

  • Creates a DepthwiseConv2D layer with the specified filter shape, strides, padding, and element-wise activation function.

    Declaration

    public init(
      filterShape: (Int, Int, Int, Int),
      strides: (Int, Int) = (1, 1),
      padding: Padding = .valid,
      activation: @escaping Activation = identity,
      useBias: Bool = true,
      filterInitializer: ParameterInitializer<Scalar> = glorotUniform(),
      biasInitializer: ParameterInitializer<Scalar> = zeros()
    )

    Parameters

    filterShape

    The shape of the 4-D convolution kernel with form, [filter width, filter height, input channel count, channel multiplier].

    strides

    The strides of the sliding window for spatial/spatio-temporal dimensions.

    padding

    The padding algorithm for convolution.

    activation

    The element-wise activation function.

    filterInitializer

    Initializer to use for the filter parameters.

    biasInitializer

    Initializer to use for the bias parameters.