Convolution2D

public struct Convolution2D<Element, Device> : LayerType, Codable where Element : RandomizableType, Device : DeviceType

A 2D convolutional layer

  • Declaration

    Swift

    public var parameterPaths: [WritableKeyPath<`Self`, Tensor<Element, Device>>] { get }
  • Convolution filters, shape [outputChannels, inputChannels, kernelHeight, kernelWidth]

    Declaration

    Swift

    public var filters: Tensor<Element, Device>
  • Bias, shape [1, outputChannels, 1, 1]

    Declaration

    Swift

    public var bias: Tensor<Element, Device>
  • Undocumented

    Declaration

    Swift

    public let stride: Int
  • Undocumented

    Declaration

    Swift

    public let padding: Int?
  • Declaration

    Swift

    public var parameters: [Tensor<Element, Device>] { get }
  • Creates a 2D convolutional layer.

    The inputs of the layer must have a shape [batchSize, channels, height, width]

    Declaration

    Swift

    public init(inputChannels: Int, outputChannels: Int, kernelSize: (width: Int, height: Int), padding: Int? = nil, stride: Int = 1)

    Parameters

    inputChannels

    Number of channels in the input

    outputChannels

    Number of channels in the output

    kernelSize

    Width and height of the convolution kernel

    padding

    Padding, that will be applied around the edges of the input

    stride

    Stride, with which the convolution kernel is moved over the input tensor, >= 1.

  • Declaration

    Swift

    public func callAsFunction(_ inputs: Tensor<Element, Device>) -> Tensor<Element, Device>