Save Tensorflow graph for viewing in Tensorboard without summary operations

后端 未结 5 2265
南旧
南旧 2021-01-01 17:55

I have a rather complicated Tensorflow graph that I\'d like to visualize for optimization purposes. Is there a function that I can call that will simply save the graph for v

5条回答
  •  盖世英雄少女心
    2021-01-01 18:01

    You can also dump the graph as a GraphDef protobuf and load that directly in TensorBoard. You can do this without starting a session or running the model.

    ## ... create graph ...
    >>> graph_def = tf.get_default_graph().as_graph_def()
    >>> graphpb_txt = str(graph_def)
    >>> with open('graphpb.txt', 'w') as f: f.write(graphpb_txt)
    

    This will output a file that looks something like this, depending on the specifics of your model.

    node {
      name: "W"
      op: "Const"
      attr {
        key: "dtype"
        value {
          type: DT_FLOAT
        }
      }
    ...
    version 1
    

    In TensorBoard you can then use the "Upload" button to load it from disk.

提交回复
热议问题