【问题标题】:Display Keras graph in Tensorboard without using the callback in the fit method在 Tensorboard 中显示 Keras 图而不使用 fit 方法中的回调
【发布时间】:2018-11-26 15:40:37
【问题描述】:

是否可以在不使用 fit 方法中的 tensorboard 回调的情况下在 Tensorboard 中显示 Keras 图?

是否可以从 Keras 中提取图形并使用 tensorflow FileWriter 显示图形? tf.summary.FileWriter(logdir='logdir', graph=graph)

我想这样做是为了检查这部分图表的所有连接是否符合预期(这个模型是一个远未完成的更大模型的一部分)。

谢谢。

【问题讨论】:

    标签: python-3.x tensorflow keras tensorboard


    【解决方案1】:

    通过从后端提取 Tensorflow 图并使用文件编写器,结果非常简单。

    import tensorflow as tf
    # Used to get the graph
    from tensorflow.python.keras import backend as K
    
    
    tb_path = "logs/"
    
    # Simple model to test the tensorboard plotting
    model = SimpleModel(50, 20, 10).build_model()
    
    # Get the sessions graph
    graph = K.get_session().graph
    
    # Display with the tensorflow file writer
    writer = tf.summary.FileWriter(logdir=tb_path, graph=graph)
    

    【讨论】:

      猜你喜欢
      • 2017-11-25
      • 2019-02-27
      • 1970-01-01
      • 2017-10-02
      • 2017-06-26
      • 2017-04-18
      • 2019-02-27
      • 2017-01-08
      • 2021-06-01
      相关资源
      最近更新 更多