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

Function clear_session

tensorflow/python/keras/backend.py:220–244  ·  view source on GitHub ↗

Destroys the current TF graph and creates a new one. Useful to avoid clutter from old models / layers.

()

Source from the content-addressed store, hash-verified

218
219@keras_export('keras.backend.clear_session')
220def clear_session():
221 """Destroys the current TF graph and creates a new one.
222
223 Useful to avoid clutter from old models / layers.
224 """
225 global _SESSION
226 global _GRAPH_LEARNING_PHASES # pylint: disable=global-variable-not-assigned
227 global _GRAPH_VARIABLES # pylint: disable=global-variable-not-assigned
228 global _GRAPH_TF_OPTIMIZERS # pylint: disable=global-variable-not-assigned
229 global _GRAPH
230 global _FREEZABLE_VARS
231 _GRAPH = None
232 ops.reset_default_graph()
233 reset_uids()
234 _SESSION.session = None
235 graph = get_graph()
236 with graph.as_default():
237 with name_scope(''):
238 phase = array_ops.placeholder_with_default(
239 False, shape=(), name='keras_learning_phase')
240 _GRAPH_LEARNING_PHASES = {}
241 _GRAPH_LEARNING_PHASES[graph] = phase
242 _GRAPH_VARIABLES.pop(graph, None)
243 _GRAPH_TF_OPTIMIZERS.pop(graph, None)
244 _FREEZABLE_VARS.pop(graph, None)
245
246
247@keras_export('keras.backend.manual_variable_initialization')

Callers

nothing calls this directly

Calls 5

reset_uidsFunction · 0.85
get_graphFunction · 0.85
name_scopeFunction · 0.70
as_defaultMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected