Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between .pb and .pbtxt in tensorflow?

When saving a graph in tensorflow

tf.train.write_graph(
    graph_or_graph_def,
    logdir,
    name,
    as_text=True
)

There is this flag: as_text: If True, writes the graph as an ASCII proto.

I found out that if it is False it saves the graph as a binary proto.

  • My question is what is the difference between those two protos?
  • And why is there a difference?
  • Do they have advantages over another?
like image 899
mrk Avatar asked Aug 21 '18 12:08

mrk


1 Answers

Thanks to a comment this question can be answered (text is from here)

Text or Binary?

There are actually two different formats that a ProtoBuf can be saved in.

  • TextFormat

    is a human-readable form, which makes it nice for debugging and editing, but can get large when there's numerical data like weights stored in it. You can see a small example of that in graph_run_run2.pbtxt.

  • Binary Format

    files are a lot smaller than their text equivalents, even though they're not as readable for us. In this script, we ask the user to supply a flag indicating whether the input file is binary or text, so we know the right function to call. You can find an example of a large binary file inside the inception_v3 archive, as inception_v3_2016_08_28_frozen.pb.

like image 74
mrk Avatar answered Sep 17 '22 18:09

mrk