Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A simple case of Graph visualization in TensorFlow 2.0

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')
like image 876
Ujjwal Avatar asked Mar 30 '19 15:03

Ujjwal


Video Answer


1 Answers

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.

like image 139
Vlad Avatar answered Nov 06 '22 05:11

Vlad