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)
| 302 | |
| 303 | |
| 304 | def _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 | |
| 323 | def symbolic_learning_phase(): |
no test coverage detected