Skip to content

Debugging

Meinrad Recheis edited this page Apr 10, 2019 · 5 revisions

Printing out the Graph

To print out a text representation of the current graph:

tf.train.export_meta_graph(@"sharp.meta.txt", as_text:true);

Doing this in both TensorFlow.NET and Python allows you to compare the graph nodes with a text diffing tool.

Graph Visualization using Tensorboard

To visualize the TensorFlow.NET-graph with Tensorboard, first export it as binary meta file:

tf.train.export_meta_graph(@"sharp.meta", as_text:false);

Then use Python to convert the meta format into an event file:

`import tensorflow tf=tensorflow

saver = tf.train.import_meta_graph("sharp.meta") writer = tf.summary.FileWriter(logdir="c:/tensorboard/logdir", graph=tf.get_default_graph()) # write to event writer.flush() `

Start Tensorboard:

tensorboard --logdir C:\tensorboard\logdir

Which will visualize the graph nicely.

tensorflow graph

Doing the same in Python is much easier, we can directly write the event file:

writer = tf.summary.FileWriter(logdir="D:/dev/tensorboard/logdir", graph=tf.get_default_graph()) # write to event writer.flush()

Comparing the viszalized graphs can make finding bugs a lot easier.

Clone this wiki locally