Alessandro
Alessandro

Reputation: 123

How to visualize a Tensorflow Model from its summary?

I am working with a custom Tensorflow model (not a Keras object) with a mostly unknown structure, and I printed the summary with this (taken from Is there an easy way to get something like Keras model.summary in Tensorflow?):

def model_summary():
    model_vars = tf.trainable_variables()
    slim.model_analyzer.analyze_vars(model_vars, print_info=True)

model_summary() 

The result is the following (I am reporting only a part of it):

---------
Variables: name (type shape) [size]
---------
model/temb/dense0/W:0 (float32_ref 128x512) [65536, bytes: 262144]
model/temb/dense0/b:0 (float32_ref 512) [512, bytes: 2048]
model/temb/dense1/W:0 (float32_ref 512x512) [262144, bytes: 1048576]
model/temb/dense1/b:0 (float32_ref 512) [512, bytes: 2048]
model/conv_in/W:0 (float32_ref 3x3x1x128) [1152, bytes: 4608]
model/conv_in/b:0 (float32_ref 128) [128, bytes: 512]
model/down_0/block_0/norm1/beta:0 (float32_ref 128) [128, bytes: 512]
model/down_0/block_0/norm1/gamma:0 (float32_ref 128) [128, bytes: 512]
model/down_0/block_0/conv1/W:0 (float32_ref 3x3x128x128) [147456, bytes: 589824]
model/down_0/block_0/conv1/b:0 (float32_ref 128) [128, bytes: 512]

How can I convert this into a clearer scheme, like a png that I can visualize? For example: enter image description here

EDIT: The graph I'm referring to is the same as the graph.pbtxt file here: https://www.dropbox.com/sh/pm6tn31da21yrx4/AADobrMR1hqHGnVV3SBOMPTJa/diffusion_celebahq_model?dl=0&subfolder_nav_tracking=1

Upvotes: 1

Views: 1764

Answers (1)

Altay Akkus
Altay Akkus

Reputation: 325

This diagram was most likely made by a human.

Labels like "copy and crop" are not typically derived from your raw model, maybe you could train a model for it ;D

There are many frameworks which can visualize your Tensorflow Model, Tensorflow has it's own suite Tensorboard.

See this example:

enter image description here

If you want anything else, look at this thread over at Data Science Stack Exchange

Upvotes: 1

Related Questions