【问题标题】:Set up tensorboard on Matterport - Mask RCNN在 Matterport 上设置 tensorboard - Mask RCNN
【发布时间】:2020-01-23 09:32:45
【问题描述】:

我正在关注这个tutorial,使用Matterport repo 进行图像检测。 我尝试关注此guide 并将代码编辑为

如何编辑以下代码以可视化张量板?

import tensorflow as tf
import datetime
%load_ext tensorboard

sess = tf.Session()

file_writer = tf.summary.FileWriter('/path/to/logs', sess.graph)

然后在模型区

# prepare config
config = KangarooConfig()
config.display()

# define the model
model = MaskRCNN(mode='training', model_dir='./', config=config)
model.keras_model.metrics_tensors = []


# Tensorflow board
logdir = os.path.join(
    "logs", datetime.datetime.now().strftime("%Y%m%d-%H%M%S"))
tensorboard_callback = tf.keras.callbacks.TensorBoard(logdir, histogram_freq=1)

# load weights (mscoco) and exclude the output layers
model.load_weights('mask_rcnn_coco.h5',
                   by_name=True,
                   exclude=[
                       "mrcnn_class_logits", "mrcnn_bbox_fc", "mrcnn_bbox",
                       "mrcnn_mask"
                   ])

# train weights (output layers or 'heads')
model.train(train_set,
            test_set,
            learning_rate=config.LEARNING_RATE,
            epochs=5,
            layers='heads')

我不知道去哪里callbacks=[tensorboard_callback]?

【问题讨论】:

    标签: python tensorflow keras tensorboard


    【解决方案1】:

    在你的model.train中,如果你仔细查看源代码文档,有一个名为custom_callbacks的参数,默认为None。

    您需要在此处编写代码,因此要使用自定义回调进行训练,您需要添加以下代码行:

    model.train(train_set,
                test_set,
                learning_rate=config.LEARNING_RATE,
                custom_callbacks = [tensorboard_callback],
                epochs=5,
                layers='heads')
    

    【讨论】:

      【解决方案2】:

      您只需要打开 Anaconda Prompt 并写入tensorboard --logdir= yourlogdirectory,其中yourlogdirectory 是包含模型检查点的目录。

      它应该看起来像这样:logs\xxxxxx20200528T1755,其中 xxxx 代表您为配置指定的名称。

      此命令将生成一个网址,将其复制到我们偏好的浏览器中。

      【讨论】:

        猜你喜欢
        • 2020-06-27
        • 1970-01-01
        • 1970-01-01
        • 2020-12-05
        • 1970-01-01
        • 2020-09-25
        • 2020-09-26
        • 2023-01-30
        • 1970-01-01
        相关资源
        最近更新 更多