TransposedConv2D

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

A 2-D transposed convolution layer (e.g. spatial transposed convolution over images).

This layer creates a convolution filter that is transpose-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 paddingIndex property allows us to handle computation based on padding.

    Declaration

    @noDerivative
    public let paddingIndex: Int
  • The element-wise activation function type.

    Declaration

    public typealias Activation = @differentiable (Tensor<Scalar>) -> Tensor<Scalar>
  • Creates a TransposedConv2D 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

    A 4-D tensor of shape [height, width, output channel count, input channel count].

    bias

    The bias tensor of shape [output channel count].

    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.

    Return Value

    The output.

  • Creates a TransposedConv2D 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

    A 4-D tensor of shape [width, height, input channel count, output channel count].

    strides

    The strides of the sliding window for spatial 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.