LSTM

public struct LSTM<Element, Device> : RNN, Codable where Element : RandomizableType, Device : DeviceType

Undocumented

  • Declaration

    Swift

    public typealias Inputs = Tensor<Element, Device>
  • Declaration

    Swift

    public typealias Outputs = (State, () -> State)
  • Undocumented

    Declaration

    Swift

    public typealias State = (hiddenState: Tensor<Element, Device>, cellState: Tensor<Element, Device>)
  • Declaration

    Swift

    public var parameterPaths: [WritableKeyPath<`Self`, Tensor<Element, Device>>] { get }
  • Undocumented

    Declaration

    Swift

    public let direction: RNNDirection
  • Wi

    Undocumented

    Declaration

    Swift

    public var Wi: Tensor<Element, Device>
  • Wo

    Undocumented

    Declaration

    Swift

    public var Wo: Tensor<Element, Device>
  • Wf

    Undocumented

    Declaration

    Swift

    public var Wf: Tensor<Element, Device>
  • Wc

    Undocumented

    Declaration

    Swift

    public var Wc: Tensor<Element, Device>
  • Ui

    Undocumented

    Declaration

    Swift

    public var Ui: Tensor<Element, Device>
  • Uo

    Undocumented

    Declaration

    Swift

    public var Uo: Tensor<Element, Device>
  • Uf

    Undocumented

    Declaration

    Swift

    public var Uf: Tensor<Element, Device>
  • Uc

    Undocumented

    Declaration

    Swift

    public var Uc: Tensor<Element, Device>
  • bi

    Undocumented

    Declaration

    Swift

    public var bi: Tensor<Element, Device>
  • bo

    Undocumented

    Declaration

    Swift

    public var bo: Tensor<Element, Device>
  • bf

    Undocumented

    Declaration

    Swift

    public var bf: Tensor<Element, Device>
  • bc

    Undocumented

    Declaration

    Swift

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

    Declaration

    Swift

    public var inputSize: Int { get }
  • Undocumented

    Declaration

    Swift

    public var hiddenSize: Int { get }
  • Declaration

    Swift

    public var parameters: [Tensor<Element, Device>] { get }
  • Creates a Long Short-Term Memory (LSTM) layer.

    The RNN expects inputs to have a shape of [sequence length, batch size, input size].

    Declaration

    Swift

    public init(inputSize: Int, hiddenSize: Int, direction: RNNDirection = .forward)

    Parameters

    inputSize

    Number of elements at each timestep of the input

    hiddenSize

    Number of elements at each timestep in the output

    direction

    Direction, in which the RNN consumes the input sequence.

  • Declaration

    Swift

    public func numberOfSteps(for inputs: Tensor<Element, Device>) -> Int
  • Declaration

    Swift

    public func initialState(for inputs: Tensor<Element, Device>) -> (hiddenState: Tensor<Element, Device>, cellState: Tensor<Element, Device>)
  • Declaration

    Swift

    public func prepare(inputs: Tensor<Element, Device>) -> (Tensor<Element, Device>, Tensor<Element, Device>, Tensor<Element, Device>, Tensor<Element, Device>)
  • Declaration

    Swift

    public func input(at step: Int, using preparedInput: (Tensor<Element, Device>, Tensor<Element, Device>, Tensor<Element, Device>, Tensor<Element, Device>)) -> (Tensor<Element, Device>, Tensor<Element, Device>, Tensor<Element, Device>, Tensor<Element, Device>)
  • Declaration

    Swift

    public func step(_ preparedInput: (Tensor<Element, Device>, Tensor<Element, Device>, Tensor<Element, Device>, Tensor<Element, Device>), previousState: State) -> State
  • Declaration

    Swift

    public func concatenate(_ states: [State]) -> State