How to graph tf.keras model in Tensorflow-2.0?

后端 未结 4 1165
别那么骄傲
别那么骄傲 2020-12-14 19:11

I upgraded to Tensorflow 2.0 and there is no tf.summary.FileWriter(\"tf_graphs\", sess.graph). I was looking through some other StackOverflow questions on this

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-14 20:00

    Here's what is working for me at the moment (TF 2.0.0), based on the tf.keras.callbacks.TensorBoard code:

    # After model has been compiled
    from tensorflow.python.ops import summary_ops_v2
    from tensorflow.python.keras.backend import get_graph
    tb_path = '/tmp/tensorboard/'
    tb_writer = tf.summary.create_file_writer(tb_path)
    with tb_writer.as_default():
        if not model.run_eagerly:
            summary_ops_v2.graph(get_graph(), step=0)
    

提交回复
热议问题