docs.unity3d.com
    Show / Hide Table of Contents

    Class LSTM

    Represents an LSTM recurrent layer. This generates an output tensor by computing a one-layer LSTM (long short-term memory) on an input tensor.

    Inheritance
    Object
    Layer
    LSTM
    Inherited Members
    Layer.inputs
    Layer.name
    Layer.outputs
    Layer.flags
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: Unity.Sentis.Layers
    Syntax
    [Serializable]
    public class LSTM : Layer

    Constructors

    LSTM(String, String[], String[], Int32, RnnDirection, RnnActivation[], Single[], Single[], Single, Boolean, RnnLayout)

    Initializes and returns an instance of a Long Short-Term Memory Network (LSTM) recurrent layer.

    Declaration
    public LSTM(string name, string[] inputs, string[] outputs, int hiddenSize, RnnDirection direction, RnnActivation[] activations = null, float[] activationAlpha = null, float[] activationBeta = null, float clip = 3.40282347E+38F, bool inputForget = false, RnnLayout layout = RnnLayout.SequenceFirst)
    Parameters
    Type Name Description
    String name

    The name to use for the first output tensor of the layer.

    String[] inputs

    The names to use for the input tensors of the layer [X, W, R, (B, sequenceLens, initialH, initialC, P)].

    X is the name of the input sequences tensor.

    W is the name of the weights tensor for the gates of the LSTM.

    R is the name of the recurrent weights tensor for the gates of the LSTM.

    B is the name of the optional bias tensor for the input gate of the LSTM.

    sequenceLens is the name of the optional 1D tensor specifying the lengths of the sequences in a batch.

    initialH is the name of the optional initial values tensor of the hidden neurons of the LSTM. If this is null then 0 is used.

    initialC is the name of the optional initial values tensor of the cells of the LSTM. If this is null then 0 is used.

    P is the name of the optional weight tensor for the peepholes of the LSTM. If this is null then 0 is used.///

    String[] outputs

    The names for the output tensors of the layer [Y, Y_h, Y_c].

    Y is the name of the concatenated intermediate output values tensor of the hidden neurons.

    Y_h is the name of the last output values tensor of the hidden neurons.

    Y_c is the name of the last output values tensor of the cells.

    Int32 hiddenSize

    The number of neurons in the hidden layer of the LSTM.

    RnnDirection direction

    The direction of the LSTM as an RnnDirection.

    RnnActivation[] activations

    The activation functions of the LSTM as an array of RnnActivation. If this is null then the LSTM uses the corresponding defaults for the given activations.

    Single[] activationAlpha

    The alpha values of the activation functions of the LSTM.

    If this is null then the LSTM uses [0, 0, 0...].

    Single[] activationBeta

    The beta values of the activation functions of the LSTM.

    If this is null then the LSTM uses the corresponding defaults for the given activations.

    Single clip

    The cell clip threshold of the LSTM. The default value is float.MaxValue.

    Boolean inputForget

    Whether to forget the input values in the LSTM. If this is false the input and forget gates are coupled. The default value is false.

    RnnLayout layout

    The layout of the tensors as an RnnLayout. The default value is RnnLayout.SequenceFirst.

    Fields

    activationAlpha

    The alpha values of the activation functions of the LSTM.

    Declaration
    public float[] activationAlpha
    Field Value
    Type Description
    Single[]

    activationBeta

    The beta values of the activation functions of the LSTM.

    Declaration
    public float[] activationBeta
    Field Value
    Type Description
    Single[]

    activations

    The activation functions of the LSTM as an array of RnnActivation.

    Declaration
    public RnnActivation[] activations
    Field Value
    Type Description
    RnnActivation[]

    clip

    The cell clip threshold of the LSTM.

    Declaration
    public float clip
    Field Value
    Type Description
    Single

    direction

    The direction of the LSTM as an RnnDirection.

    Declaration
    public RnnDirection direction
    Field Value
    Type Description
    RnnDirection

    hiddenSize

    The number of neurons in the hidden layer of the LSTM.

    Declaration
    public int hiddenSize
    Field Value
    Type Description
    Int32

    inputForget

    Whether to forget the input values in the LSTM. If this is false the input and forget gates are coupled.

    Declaration
    public bool inputForget
    Field Value
    Type Description
    Boolean

    layout

    The layout of the tensors as an RnnLayout.

    Declaration
    public RnnLayout layout
    Field Value
    Type Description
    RnnLayout

    Properties

    NumDirections

    The number of directions of the LSTM inferred from the direction.

    Declaration
    public int NumDirections { get; }
    Property Value
    Type Description
    Int32

    Methods

    Execute(Tensor[], ExecutionContext)

    Executes the layer using the operations and variables from the ExecutionContext and returns the output tensor.

    If the layer has more than one output, output tensors are saved to variables.

    Declaration
    public override Tensor Execute(Tensor[] inputTensors, ExecutionContext ctx)
    Parameters
    Type Name Description
    Tensor[] inputTensors
    ExecutionContext ctx
    Returns
    Type Description
    Tensor
    Overrides
    Layer.Execute(Tensor[], ExecutionContext)

    ToString()

    Returns a string that represents the Layer.

    Declaration
    public override string ToString()
    Returns
    Type Description
    String
    Overrides
    Layer.ToString()
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023