在iwn10下,利用keras在模型保存和tensorboard可视化中遇到一个坑:“No dashboards are active for the current data set.”,在此做个记录。
1. 训练结果保存
hist=model.fit(train_set_x,train_set_y,batch_size=256)
# 或 hist=model.fit_generator(gen,batch_size=256)
with open('log_027.txt','w') as f:
f.write(str(hist.history))
2. 利用Tensorboard可视化训练
参考:https://blog.****.net/dugudaibo/article/details/77961836
from keras.callbacks import TensorBoard
model.fit(train_data, train_labels,
nb_epoch=400, batch_size=32,
callbacks=[TensorBoard(log_dir='mytensorboard/3')]) # log_dir是tensorboard文件保存地址
之后在终端中输入
tensorboard --logdir='/home/lib321/my_keras/mytensorboard/3'
打开Google浏览器,输入网址后,出现问题:“No dashboards are active for the current data set.”
解决(参考链接):
1、cmd命令,切换到log文件夹的上一层目录,
(base)c:\> cd E:\Experiments
2、输入:
(base)E:\Experiments> tensorboard --logdir=tensorboard\025
注:我的log保存在了E:\Experiments\tensorboard\025文件夹中,之前报错,都是因为目录地址前后加了引号。win10下的tensorboard直接如此设置路径即可。
最后,祭图。