【问题标题】:TensorBoard: How to write images to get a steps slider?TensorBoard:如何编写图像以获得步骤滑块?
【发布时间】:2018-12-31 22:59:25
【问题描述】:

我在我的 ML 项目中使用带有 TensorBoard 回调的 keras。我有一个图像自动编码器,我想可视化它在重建一些图像方面的进展。所以我将TensorBoard 类归为这样:

class Monitor(TensorBoard):
    def on_train_begin(self, logs=None):
        super().on_train_begin(logs)
    def on_epoch_begin(self, epoch, logs=None):

        # 1. Get the reconstructed images
        reconstructions = Autoencoder.predict(validation[0])

        # 2. Generate a summary
        summary = tf.summary.image('reconstructions', expand_dims(gallery(reconstructions), axis=0), family='reconstructions')

        # 3. Add the summary with `epoch` as the step
        self.writer.add_summary(summary.eval(), epoch)

        super().on_epoch_begin(epoch, logs)

gallery 函数只是从一批图像中生成单个图像)

运行代码时我在TensorBoard 中看到的是this screenshot。 每张图片都写有不同的名称,TensorBoard 无法使用单个滑块在它们之间切换。

如何编写图像摘要,以便TensorBoard 给我一个滑块来选择不同的步骤?

【问题讨论】:

    标签: tensorflow keras visualization tensorboard autoencoder


    【解决方案1】:

    图片必须有相同的tag(不是name,我之前是这样做的)。

    plt.figure(figsize=(5,5))
    plt.plot([0, 1], [0, 1], "k:", label="Perfectly calibrated")
    plt.plot(mean_predicted_values, fraction_of_positives)
    reliability_image = io.BytesIO()
    plt.savefig(reliability_image, format='png')
    reliability_image = tf.Summary.Image(encoded_image_string=reliability_image.getvalue(),
                                       height=7,
                                       width=7)
    summary = tf.Summary(value=[tf.Summary.Value(tag="Reliability", 
    image=reliability_image)])
    
    writer_train.add_summary(summary, global_step=epoch)
    

    enter image description here

    【讨论】:

      猜你喜欢
      • 2017-10-01
      • 2012-10-24
      • 2018-05-31
      • 2021-07-20
      • 2019-08-20
      • 2020-03-18
      • 2017-04-28
      • 2016-05-20
      • 1970-01-01
      相关资源
      最近更新 更多