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

Function _mark_func_graph_as_unsaveable

tensorflow/python/keras/backend.py:304–320  ·  view source on GitHub ↗

Mark func graph as unsaveable due to use of symbolic keras learning phase. Functions that capture the symbolic learning phase cannot be exported to SavedModel. Mark the funcgraph as unsaveable, so that an error will be raised if it is exported. Args: graph: Graph or FuncGraph object.

(graph, learning_phase)

Source from the content-addressed store, hash-verified

302
303
304def _mark_func_graph_as_unsaveable(graph, learning_phase):
305 """Mark func graph as unsaveable due to use of symbolic keras learning phase.
306
307 Functions that capture the symbolic learning phase cannot be exported to
308 SavedModel. Mark the funcgraph as unsaveable, so that an error will be raised
309 if it is exported.
310
311 Args:
312 graph: Graph or FuncGraph object.
313 learning_phase: Learning phase placeholder or int defined in the graph.
314 """
315 if graph.building_function and is_placeholder(learning_phase):
316 graph.mark_as_unsaveable(
317 'The keras learning phase placeholder was used inside a function. '
318 'Exporting placeholders is not supported when saving out a SavedModel. '
319 'Please call `tf.keras.backend.set_learning_phase(0)` in the function '
320 'to set the learning phase to a constant value.')
321
322
323def symbolic_learning_phase():

Callers 1

learning_phaseFunction · 0.85

Calls 2

is_placeholderFunction · 0.85
mark_as_unsaveableMethod · 0.80

Tested by

no test coverage detected