# tf.contrib.tpu.while_loop

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/tpu/training_loop.py#L30-L178) |

Builds a training loop for TPUs.

    tf.contrib.tpu.while_loop(
        condition, body, inputs=None, infeed_queue=None, name=None
    )

The set of loop-carried tensors corresponds to `inputs`. Both
`condition` and `body` take the current value of the loop-carried
tensors. 'body' additionally takes a tuple of infeed from
infeed_queue if infeed_queue is not None. `condition` must return a
single boolean value that determines whether iteration
continues. `body` must return an updated list of values for the
loop-carried tensors.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `condition` | a Python function that builds the loop condition. |
| `body` | a Python function that builds the loop body. |
| `inputs` | a list of initial values passed into the training loop, or None (equivalent to an empty list). |
| `infeed_queue` | if not None, the infeed queue from which to append a tuple of arguments as inputs to condition. |
| `name` | (Deprecated) Does nothing. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| The final values of the loop-carried tensors. ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `TypeError` | if body or condition has the wrong signature. |

<br />