This op first slices input along the dimension batch_axis, and for
each slice i, reverses the first seq_lengths[i] elements along the
dimension seq_axis.
The elements of seq_lengths must obey seq_lengths[i] <=
input.dims[seq_axis], and seq_lengths must be a vector of length
input.dims[batch_axis].
The output slice i along dimension batch_axis is then given by
input slice i, with the first seq_lengths[i] slices along
dimension seq_axis reversed.
[null,null,["Last updated 2024-04-26 UTC."],[],[],null,["# tf.compat.v1.reverse_sequence\n\n\u003cbr /\u003e\n\n|-------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/python/ops/array_ops.py#L4624-L4687) |\n\nReverses variable length slices. (deprecated arguments) (deprecated arguments) \n\n tf.compat.v1.reverse_sequence(\n input,\n seq_lengths,\n seq_axis=None,\n batch_axis=None,\n name=None,\n seq_dim=None,\n batch_dim=None\n )\n\n| **Deprecated:** SOME ARGUMENTS ARE DEPRECATED: `(seq_dim)`. They will be removed in a future version. Instructions for updating: seq_dim is deprecated, use seq_axis instead\n| **Deprecated:** SOME ARGUMENTS ARE DEPRECATED: `(batch_dim)`. They will be removed in a future version. Instructions for updating: batch_dim is deprecated, use batch_axis instead\n\nThis op first slices `input` along the dimension `batch_axis`, and for\neach slice `i`, reverses the first `seq_lengths[i]` elements along the\ndimension `seq_axis`.\n\nThe elements of `seq_lengths` must obey `seq_lengths[i] \u003c=\ninput.dims[seq_axis]`, and `seq_lengths` must be a vector of length\n`input.dims[batch_axis]`.\n\nThe output slice `i` along dimension `batch_axis` is then given by\ninput slice `i`, with the first `seq_lengths[i]` slices along\ndimension `seq_axis` reversed.\n\n#### Example usage:\n\n seq_lengths = [7, 2, 3, 5]\n input = [[1, 2, 3, 4, 5, 0, 0, 0], [1, 2, 0, 0, 0, 0, 0, 0],\n [1, 2, 3, 4, 0, 0, 0, 0], [1, 2, 3, 4, 5, 6, 7, 8]]\n output = tf.reverse_sequence(input, seq_lengths, seq_axis=1, batch_axis=0)\n output\n \u003ctf.Tensor: shape=(4, 8), dtype=int32, numpy=\n array([[0, 0, 5, 4, 3, 2, 1, 0],\n [2, 1, 0, 0, 0, 0, 0, 0],\n [3, 2, 1, 4, 0, 0, 0, 0],\n [5, 4, 3, 2, 1, 6, 7, 8]], dtype=int32)\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|---------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `input` | A `Tensor`. The input to reverse. |\n| `seq_lengths` | A `Tensor`. Must be one of the following types: `int32`, `int64`. 1-D with length `input.dims(batch_axis)` and `max(seq_lengths) \u003c= input.dims(seq_axis)` |\n| `seq_axis` | An `int`. The dimension which is partially reversed. |\n| `batch_axis` | An optional `int`. Defaults to `0`. The dimension along which reversal is performed. |\n| `name` | A name for the operation (optional). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A Tensor. Has the same type as input. ||\n\n\u003cbr /\u003e"]]