# tf.keras.backend.learning_phase_scope

<br />

|---|---|
| [![](https://www.tensorflow.org/images/tf_logo_32px.png) TensorFlow 1 version](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/backend/learning_phase_scope) | [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/keras/backend.py#L360-L402) |

Provides a scope within which the learning phase is equal to `value`.

#### View aliases


**Compat aliases for migration**

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

[`tf.compat.v1.keras.backend.learning_phase_scope`](https://www.tensorflow.org/api_docs/python/tf/keras/backend/learning_phase_scope)

<br />

    @tf_contextlib.contextmanager
    tf.keras.backend.learning_phase_scope(
        value
    )

The learning phase gets restored to its original value upon exiting the scope.

<br />

<br />

<br />

| ## Arguments ||
|---|---|
| `value` | Learning phase value, either 0 or 1 (integers). |

<br />

#### Yields:

None.

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `ValueError` | if `value` is neither `0` nor `1`. |

<br />