Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to make tensorflow graph summary?

I'm aware of Tensorboard and how awesome it is, but I think that simple console output with current graph summary is better (and faster) for prototyping purpose. And also know that I can generate tensorboard graph after simply running session with last network node as shown here.

What I'm looking for is something similar to model.summary() from Keras.

In another words: how to iterate over tensorflow graph and print out only custom high end layer with their shapes and dtypes in the same order how all these layer where generated?

like image 882
aiven Avatar asked Feb 15 '18 12:02

aiven


2 Answers

It's certainly possible. If you are using tf.keras wrapper to build you can easily visualize the graph, even before model.compile() method executes. It's keras built-in functionality called plot_model().
*This method have dependency on graphviz and pydot libraries.
for pydot installation : pip install pydot
but for graphviz installation you have follow step in this page. And also probably you have to restart the machine because of there it create system environment variables.
for tutorial on how to use this method follow this link

like image 157
nipun Avatar answered Nov 14 '22 15:11

nipun


To plot your model with shapes and dtypes before training you could use:

tf.keras.utils.plot_model(model, show_shapes=True, expand_nested=True, show_dtype=True)

where "model" is your built model. The output of a model could looks like this: enter image description here

like image 34
Sascha Kirch Avatar answered Nov 14 '22 14:11

Sascha Kirch