# tf.keras.layers.StackedRNNCells

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/keras-team/keras/tree/v2.13.1/keras/layers/rnn/stacked_rnn_cells.py#L34-L217) |

Wrapper allowing a stack of RNN cells to behave as a single cell.

Inherits From: [`Layer`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/keras/layers/Layer), [`Module`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/Module)

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

\`tf.compat.v1.keras.layers.StackedRNNCells\`

<br />

    tf.keras.layers.StackedRNNCells(
        cells, **kwargs
    )

Used to implement efficient stacked RNNs.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `cells` | List of RNN cell instances. |

<br />

#### Examples:

    batch_size = 3
    sentence_max_length = 5
    n_features = 2
    new_shape = (batch_size, sentence_max_length, n_features)
    x = tf.constant(np.reshape(np.arange(30), new_shape), dtype = tf.float32)

    rnn_cells = [tf.keras.layers.LSTMCell(128) for _ in range(2)]
    stacked_lstm = tf.keras.layers.StackedRNNCells(rnn_cells)
    lstm_layer = tf.keras.layers.RNN(stacked_lstm)

    result = lstm_layer(x)

<br />

<br />

<br />

| ## Attributes ||
|---|---|
| `output_size` | <br /> <br /> |
| `state_size` | <br /> <br /> |

<br />

## Methods

### `get_initial_state`

[View source](https://github.com/keras-team/keras/tree/v2.13.1/keras/layers/rnn/stacked_rnn_cells.py#L106-L125)

    get_initial_state(
        inputs=None, batch_size=None, dtype=None
    )