An initial state can be provided.
If the sequence_length vector is provided, dynamic calculation is performed.
This method of calculation does not compute the RNN steps past the maximum
sequence length of the minibatch (thus saving computational time),
and properly propagates the state at an example's sequence length
to the final state output.
The dynamic calculation performed is, at time t for batch row b,
A length T list of inputs, each a Tensor of shape [batch_size,
input_size], or a nested tuple of such elements.
initial_state
(optional) An initial state for the RNN. If cell.state_size
is an integer, this must be a Tensor of appropriate type and shape
[batch_size, cell.state_size]. If cell.state_size is a tuple, this
should be a tuple of tensors having shapes [batch_size, s] for s in
cell.state_size.
dtype
(optional) The data type for the initial state and expected output.
Required if initial_state is not provided or RNN state has a heterogeneous
dtype.
sequence_length
Specifies the length of each sequence in inputs. An int32
or int64 vector (tensor) size [batch_size], values in [0, T).
scope
VariableScope for the created subgraph; defaults to "rnn".
Returns
A pair (outputs, state) where:
outputs is a length T list of outputs (one for each input), or a nested
tuple of such elements.
state is the final state
Raises
TypeError
If cell is not an instance of RNNCell.
ValueError
If inputs is None or an empty list, or if the input depth
(column size) cannot be inferred from inputs via shape inference.
[null,null,["Last updated 2024-04-26 UTC."],[],[],null,["# tf.compat.v1.nn.static_rnn\n\n\u003cbr /\u003e\n\n|-------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/python/ops/rnn.py#L1311-L1488) |\n\nCreates a recurrent neural network specified by RNNCell `cell`. (deprecated) \n\n tf.compat.v1.nn.static_rnn(\n cell,\n inputs,\n initial_state=None,\n dtype=None,\n sequence_length=None,\n scope=None\n )\n\n| **Deprecated:** THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: Please use [`keras.layers.RNN(cell, unroll=True)`](https://www.tensorflow.org/api_docs/python/tf/keras/layers/RNN), which is equivalent to this API\n\nThe simplest form of RNN network generated is: \n\n state = cell.zero_state(...)\n outputs = []\n for input_ in inputs:\n output, state = cell(input_, state)\n outputs.append(output)\n return (outputs, state)\n\nHowever, a few other options are available:\n\nAn initial state can be provided.\nIf the sequence_length vector is provided, dynamic calculation is performed.\nThis method of calculation does not compute the RNN steps past the maximum\nsequence length of the minibatch (thus saving computational time),\nand properly propagates the state at an example's sequence length\nto the final state output.\n\nThe dynamic calculation performed is, at time `t` for batch row `b`, \n\n (output, state)(b, t) =\n (t \u003e= sequence_length(b))\n ? (zeros(cell.output_size), states(b, sequence_length(b) - 1))\n : cell(input(b, t), state(b, t - 1))\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `cell` | An instance of RNNCell. |\n| `inputs` | A length T list of inputs, each a `Tensor` of shape `[batch_size, input_size]`, or a nested tuple of such elements. |\n| `initial_state` | (optional) An initial state for the RNN. If `cell.state_size` is an integer, this must be a `Tensor` of appropriate type and shape `[batch_size, cell.state_size]`. If `cell.state_size` is a tuple, this should be a tuple of tensors having shapes `[batch_size, s] for s in cell.state_size`. |\n| `dtype` | (optional) The data type for the initial state and expected output. Required if initial_state is not provided or RNN state has a heterogeneous dtype. |\n| `sequence_length` | Specifies the length of each sequence in inputs. An int32 or int64 vector (tensor) size `[batch_size]`, values in `[0, T)`. |\n| `scope` | VariableScope for the created subgraph; defaults to \"rnn\". |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A pair (outputs, state) where: \u003cbr /\u003e - outputs is a length T list of outputs (one for each input), or a nested tuple of such elements. - state is the final state ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|--------------|---------------------------------------------------------------------------------------------------------------------------------|\n| `TypeError` | If `cell` is not an instance of RNNCell. |\n| `ValueError` | If `inputs` is `None` or an empty list, or if the input depth (column size) cannot be inferred from inputs via shape inference. |\n\n\u003cbr /\u003e"]]