# tf.data.experimental.take_while

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.14.0/tensorflow/python/data/experimental/ops/take_while_ops.py#L20-L38) |

A transformation that stops dataset iteration based on a `predicate`. (deprecated)

#### View aliases


**Compat aliases for migration**

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

[`tf.compat.v1.data.experimental.take_while`](https://www.tensorflow.org/api_docs/python/tf/data/experimental/take_while)

<br />

    tf.data.experimental.take_while(
        predicate
    )

> [!WARNING]
> **Deprecated:** THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: Use \`tf.data.Dataset.take_while(...)

<br />

<br />

<br />

| ## Args ||
|---|---|
| `predicate` | A function that maps a nested structure of tensors (having shapes and types defined by `self.output_shapes` and `self.output_types`) to a scalar [`tf.bool`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf#bool) tensor. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A `Dataset` transformation function, which can be passed to [`tf.data.Dataset.apply`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/data/Dataset#apply). ||

<br />