MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / set_learning_phase

Function set_learning_phase

tensorflow/python/keras/backend.py:335–352  ·  view source on GitHub ↗

Sets the learning phase to a fixed value. Arguments: value: Learning phase value, either 0 or 1 (integers). Raises: ValueError: if `value` is neither `0` nor `1`.

(value)

Source from the content-addressed store, hash-verified

333
334@keras_export('keras.backend.set_learning_phase')
335def set_learning_phase(value):
336 """Sets the learning phase to a fixed value.
337
338 Arguments:
339 value: Learning phase value, either 0 or 1 (integers).
340
341 Raises:
342 ValueError: if `value` is neither `0` nor `1`.
343 """
344 global _GRAPH_LEARNING_PHASES # pylint: disable=global-variable-not-assigned
345 if value not in {0, 1}:
346 raise ValueError('Expected learning phase to be 0 or 1.')
347 with ops.init_scope():
348 if context.executing_eagerly():
349 # In an eager context, the learning phase values applies to both the eager
350 # context and the internal Keras graph.
351 _GRAPH_LEARNING_PHASES[_DUMMY_EAGER_GRAPH] = value
352 _GRAPH_LEARNING_PHASES[get_graph()] = value
353
354
355@keras_export('keras.backend.learning_phase_scope')

Callers 1

learning_phase_scopeFunction · 0.85

Calls 2

get_graphFunction · 0.85
executing_eagerlyMethod · 0.80

Tested by

no test coverage detected