[英]Set up tensorboard on Matterport - Mask RCNN
I am following this tutorial for image detection using Matterport repo.我正在按照本教程使用Matterport 存储库进行图像检测。 I tried following this guide and edited the code to我尝试遵循本指南并将代码编辑为
How can I edit the following code to visualize the tensorboard ?如何编辑以下代码以可视化张量板?
import tensorflow as tf
import datetime
%load_ext tensorboard
sess = tf.Session()
file_writer = tf.summary.FileWriter('/path/to/logs', sess.graph)
And then in the model area然后在模型区
# 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')
I am not sure where to callbacks=[tensorboard_callback]
?我不确定在哪里callbacks=[tensorboard_callback]
?
In your model.train, if you look closely in the source code documentation, there is parameter called custom_callbacks
, which defaults to None
.在您的 model.train 中,如果您仔细查看源代码文档,会发现一个名为custom_callbacks
参数,该参数默认为None
。
It is there where you need to write your code, so to train with a custom callback, you will need to add this line of code:您需要在此处编写代码,因此要使用自定义回调进行训练,您需要添加以下代码行:
model.train(train_set,
test_set,
learning_rate=config.LEARNING_RATE,
custom_callbacks = [tensorboard_callback],
epochs=5,
layers='heads')
You only have to open Anaconda Prompt and write tensorboard --logdir= yourlogdirectory
, where yourlogdirectory
is the directory containing the model checkpoint.您只需打开 Anaconda Prompt 并写入tensorboard --logdir= yourlogdirectory
,其中yourlogdirectory
是包含模型检查点的目录。
It should look something like this: logs\\xxxxxx20200528T1755, where xxxx stands for the name you give to your configuration.它应该看起来像这样:logs\\xxxxxx20200528T1755,其中 xxxx 代表您为配置提供的名称。
This command will generate a web address, copy it in our browser of preference.此命令将生成一个网址,将其复制到我们首选的浏览器中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.