Dense

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

Dense (Linear, Fully connected) layer with no activation function.

  • Declaration

    Swift

    public var parameterPaths: [WritableKeyPath<`Self`, Tensor<Element, Device>>] { get }
  • Weights, shape [inputSize, outputSize]

    Declaration

    Swift

    public var weights: Tensor<Element, Device>
  • Bias, shape [outputSize]

    Declaration

    Swift

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

    Swift

    public var parameters: [Tensor<Element, Device>] { get }
  • Creates a dense / linear / fully connected layer with no output activation function.

    The layer expects inputs to have a shape of [batchSize, inputSize].

    Declaration

    Swift

    public init(inputSize: Int, outputSize: Int)

    Parameters

    inputSize

    Number of elements in an input vector

    outputSize

    Number of elements in an output vector

  • Declaration

    Swift

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