[ Keras ] ——基本使用:(5) 训练结果保存(val_loss / val_acc / train_acc) + Tensorboard可视化

1. 训练结果保存

hist=model.fit(train_set_x,train_set_y,batch_size=256)
# 或 hist=model.fit_generator(gen,batch_size=256)
with open('log_sgd_big_32.txt','w') as f:
    f.write(str(hist.history))

 

2. 利用Tensorboard可视化训练

参考:https://blog.csdn.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文件保存地址

之后打开终端,进入conda——>activate到装有tensorflow的环境中。

conda

source activate env

之后在终端中输入

tensorboard --logdir='/home/lib321/my_keras/mytensorboard/3'

 

你可能感兴趣的:([ Keras ] ——基本使用:(5) 训练结果保存(val_loss / val_acc / train_acc) + Tensorboard可视化)