tf.function
compiles a function into a callable TensorFlow graph. Documentation
@tf.function
def f(x):
return x + 1
Use the get_concrete_function
method of the callable created by tf.function. It returns a tf.Graph
object.
g = f.get_concrete_function(1).graph
isinstance(g, tf.Graph)
gdef = g.as_graph_def(add_shapes=True)
tf.io.write_graph(gdef, ".", "foo.pbtxt")