RNN

public protocol RNN : LayerType

Base protocol for recurrent neural networks.

  • Undocumented

    Declaration

    Swift

    associatedtype State where Self.Outputs == (Self.State, () -> Self.StateSequence)
  • Undocumented

    Declaration

    Swift

    associatedtype StateSequence
  • Undocumented

    Declaration

    Swift

    associatedtype PreparedInput
  • Undocumented

    Declaration

    Swift

    associatedtype StepInput
  • Undocumented

    Declaration

    Swift

    var direction: RNNDirection { get }
  • Number of steps to perform given the inputs of the RNN

    Declaration

    Swift

    func numberOfSteps(for inputs: Inputs) -> Int

    Parameters

    inputs

    Inputs of the RNN

  • Creates the initial state of the RNN for processing the given sequence

    Declaration

    Swift

    func initialState(for inputs: Inputs) -> State

    Parameters

    inputs

    Sequence to process

  • Performs the input transformation on all timesteps of the input at once

    Declaration

    Swift

    func prepare(inputs: Inputs) -> PreparedInput

    Parameters

    inputs

    Sequence to process

  • Concatenates the given array of states into a state sequence

    Declaration

    Swift

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

    Parameters

    states

    States to concatenate

  • Extracts the inputs of the RNN at a given timestep from the preprocessed input sequence

    Declaration

    Swift

    func input(at step: Int, using preparedInput: PreparedInput) -> StepInput

    Parameters

    step

    Timestep

    preparedInput

    Prepared input sequence

  • Performs a single RNN timestep

    Declaration

    Swift

    func step(_ preparedInput: StepInput, previousState: State) -> State

    Parameters

    preparedInput

    Preprocessed input for the current timestep

    previousState

    Previous hidden state

  • callAsFunction(_:state:) Default implementation

    Applies the RNN to the given input sequence using the provided initial state

    Default Implementation

    Declaration

    Swift

    func callAsFunction(_ inputs: Inputs, state: State?) -> (State, () -> StateSequence)

    Parameters

    inputs

    Input sequence

    state

    Initial state, optional

  • callAsFunction(_:) Extension method

    Declaration

    Swift

    public func callAsFunction(_ inputs: Inputs) -> Outputs