<!--
{
  "availability" : [
    "iOS: 14.0.0 - 17.4.0",
    "iPadOS: 14.0.0 - 17.4.0",
    "macCatalyst: 14.0.0 - 17.4.0",
    "macOS: 11.0.0 - 14.3.0",
    "tvOS: 14.0.0 - 17.4.0"
  ],
  "documentType" : "symbol",
  "framework" : "MLCompute",
  "identifier" : "/documentation/MLCompute/MLCLSTMLayer",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "ML Compute"
    ],
    "preciseIdentifier" : "c:objc(cs)MLCLSTMLayer"
  },
  "title" : "MLCLSTMLayer"
}
-->

# MLCLSTMLayer

A layer that represents long short-term memory (LSTM) networks.

```
class MLCLSTMLayer
```

## Overview

Use this class to create an LSTM layer with one of the following configurations:

- Unidirectional single layer: The input weights, hidden weights, and biases are arrays of 4 tensors that describe the specified weights for the input, hidden, cell, and output gates.
- Unidirectional stacked layers: The input weights, hidden weights and biases are arrays of [`layerCount`](/documentation/MLCompute/MLCLSTMDescriptor/layerCount) `* 4` tensors that describe the specified weights for the input, hidden, cell, and output gates, for `layer0...layer(layerCount - 1)`.
- Bidirectional single layer: The input weights, hidden weights, and biases are arrays of 8 tensors, where the backward time weights and biases follow the forward time weights.

## Topics

### Creating LSTM Layers

[`init(descriptor:inputWeights:hiddenWeights:biases:)`](/documentation/MLCompute/MLCLSTMLayer/init(descriptor:inputWeights:hiddenWeights:biases:))

Creates an LSTM layer with the descriptor, input and hidden weights, and biases you specify.

[`init(descriptor:inputWeights:hiddenWeights:peepholeWeights:biases:)`](/documentation/MLCompute/MLCLSTMLayer/init(descriptor:inputWeights:hiddenWeights:peepholeWeights:biases:))

Creates an LSTM layer with the descriptor, weights, and biases you specify.

[`init(descriptor:inputWeights:hiddenWeights:peepholeWeights:biases:gateActivations:outputResultActivation:)`](/documentation/MLCompute/MLCLSTMLayer/init(descriptor:inputWeights:hiddenWeights:peepholeWeights:biases:gateActivations:outputResultActivation:))

Creates an LSTM layer using the descriptor, weights, biases, gate activations, and output result activation that you specify.

[`MLCLSTMDescriptor`](/documentation/MLCompute/MLCLSTMDescriptor)

The configuration object you use to create the LSTM layer.

[`MLCLSTMResultMode`](/documentation/MLCompute/MLCLSTMResultMode)

Constants that describe the result of an LSTM layer.

### Inspecting LSTM Layers

[`descriptor`](/documentation/MLCompute/MLCLSTMLayer/descriptor)

The configuration object you use to create the LSTM layer.

[`gateActivations`](/documentation/MLCompute/MLCLSTMLayer/gateActivations)

The array of gate activations you use for input, hidden, cell, and output gates.

[`outputResultActivation`](/documentation/MLCompute/MLCLSTMLayer/outputResultActivation)

The output activation descriptor.

[`inputWeights`](/documentation/MLCompute/MLCLSTMLayer/inputWeights)

The array of tensors that describe the input weights you use for the input, hidden, cell, and output gates.

[`hiddenWeights`](/documentation/MLCompute/MLCLSTMLayer/hiddenWeights)

The array of tensors that describe the hidden weights you use for the input, hidden, cell, and output gates.

[`peepholeWeights`](/documentation/MLCompute/MLCLSTMLayer/peepholeWeights)

The array of tensors that describe the peephole weights you use for the input, hidden, cell, and output gates.

[`biases`](/documentation/MLCompute/MLCLSTMLayer/biases)

The array of tensors that describe the bias terms you use for the input, hidden, cell, and output gates.

[`inputWeightsParameters`](/documentation/MLCompute/MLCLSTMLayer/inputWeightsParameters)

The input weights tensor parameters you use for optimizer updates.

[`hiddenWeightsParameters`](/documentation/MLCompute/MLCLSTMLayer/hiddenWeightsParameters)

The hidden weights tensor parameters you use for optimizer updates.

[`peepholeWeightsParameters`](/documentation/MLCompute/MLCLSTMLayer/peepholeWeightsParameters)

The peephole weights tensor parameters you use for optimizer updates.

[`biasesParameters`](/documentation/MLCompute/MLCLSTMLayer/biasesParameters)

The biases tensor parameters you use for optimizer updates.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)