I would like to simply define a model and visualize its graph in TensorBoard for initial architectural examination. Thus, I would not like to compute anything for this purpose.
In TensorFlow 1.X, it was simple to achieve inside a tf.Session()
where I could simply flush()
a summary file writer.
In TensorFlow 2.0, there is no tf.Session()
and hence the question is how do I achieve it ?
The following is an example code. What additions do I need to make, in order for it to write the graph structure in TensorBoard ?
from nets import i3d
import tensorflow as tf
def i3d_output(model, x):
out, _ = model(x)
return out
tf.compat.v1.disable_eager_execution()
x = tf.random.uniform(shape=(4,179,224,224,3))
model = i3d.InceptionI3d()
net = i3d_output(model, x)
train_summary_writer = tf.summary.create_file_writer('/home/uujjwal/bmvc2019')
In graph mode use this:
from tensorflow.python.summary.writer.writer import FileWriter
FileWriter('logs/', graph=tf.compat.v1.get_default_graph()).close()
Or this:
tf.compat.v1.summary.FileWriter('log/', graph=tf.compat.v1.get_default_graph()).close()
No need in opening session.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With