Skip to content

Instantly share code, notes, and snippets.

@domluna
Last active April 12, 2018 23:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save domluna/f06921196b539a397a6a24ae7f571276 to your computer and use it in GitHub Desktop.
Save domluna/f06921196b539a397a6a24ae7f571276 to your computer and use it in GitHub Desktop.
Print the size in bytes of a Tensorflow GraphDef
import tensorflow as tf
def main():
files = ['model-' + str(x) for x in range(20000, 70000, 10000)]
for f in files:
with tf.Graph().as_default():
sess = tf.Session()
saver = tf.train.import_meta_graph('./test_graph_size/' + f + '.meta')
saver.restore(sess, './test_graph_size/' + f)
print(sess.graph_def.ByteSize())
if __name__ == "__main__":
main()
@domluna
Copy link
Author

domluna commented Jun 8, 2016

Outputs:

30376060
35425130
40474200
45523270
50572340

@joellerena
Copy link

joellerena commented Apr 12, 2018

I have the result of:
IOError: File ./test_graph_size/model-20000.meta does not exist.
I appreciate your comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment