Google Colab 中使用 tensorboard 绘制训练损失 loss 曲线

首先,在代码中使用 tensorboard 保存训练过程的 loss(确保已经安装了 tensorboard),可参考https://blog.csdn.net/haoshan4783/article/details/89970227

训练完毕后,使用以下代码绘制 loss 曲线:

%load_ext tensorboard
%tensorboard --logdir /your/content/directory

如果出现以下报错:

ERROR: Timed out waiting for TensorBoard to start. It may still be running as pid 4077.

则在上面的代码改为:

!pip uninstall -y tensorboard tb-nightly
!pip install -U tb-nightly
%load_ext tensorboard
%tensorboard --logdir /your/content/directory

如果出现以下报错:

TensorBoard attempted to bind to port 6006, but it was already in use

则需要手动指定端口(多尝试几个不同的端口):

!pip uninstall -y tensorboard tb-nightly
!pip install -U tb-nightly
%load_ext tensorboard
%tensorboard --logdir /your/content/directory --port 8800

你可能感兴趣的:(python,开发语言)