# tf.data.experimental.take_while

<br />

|---|---|
| [![](https://www.tensorflow.org/images/tf_logo_32px.png) TensorFlow 2 version](https://www.tensorflow.org/api_docs/python/tf/data/experimental/take_while) | [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/data/experimental/ops/take_while_ops.py#L55-L72) |

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

#### 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), \`tf.compat.v2.data.experimental.take_while\`

<br />

    tf.data.experimental.take_while(
        predicate
    )

<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/r1.15/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/r1.15/api_docs/python/tf/data/Dataset#apply). ||

<br />