<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/models/blob/v2.20.0/official/vision/ops/preprocess_ops_3d.py#L126-L178) |

Samples a single segment of size `num_frames` from a given sequence.

    tfm.vision.preprocess_ops_3d.sample_segment_sequence(
        sequence: tf.Tensor,
        num_frames: int,
        is_training: bool,
        seed: Optional[int] = None
    ) -> tf.Tensor

This function follows the temporal segment network sampling style
(<https://arxiv.org/abs/1608.00859>). The video sequence would be divided into
`num_frames` non-overlapping segments with same length. If `is_training` is
`True`, we would randomly sampling one frame for each segment, and when
`is_training` is `False`, only the center frame of each segment is sampled.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `sequence` | Any tensor where the first dimension is timesteps. |
| `num_frames` | Number of frames to take. |
| `is_training` | A boolean indicating sampling in training or evaluation mode. |
| `seed` | A deterministic seed to use when sampling. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A single [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor) with first dimension `num_steps` with the sampled segment. ||

<br />