graph = tf.Graph()
with graph.as_default():
c = tf.constant(30.0)
writer = tf.summary.create_file_writer("/tmp/mylogs")
with writer.as_default():
tf.summary.graph(graph)
# Another example; must attain the concrete function graph manually.
@tf.function
def f():
x = constant_op.constant(2)
y = constant_op.constant(3)
return x**y
with writer.as_default():
tf.summary.graph(f.get_concrete_function().graph)