我想写一个包含神经网络超参数和模型架构的 *.txt 文件。是否可以将对象 model.summary() 写入我的输出文件?
(...)
summary = str(model.summary())
(...)
out = open(filename + 'report.txt','w')
out.write(summary)
out.close
正如您在下面看到的那样,碰巧我得到了“无”。
Hyperparameters
=========================
learning_rate: 0.01
momentum: 0.8
decay: 0.0
batch size: 128
no. epochs: 3
dropout: 0.5
-------------------------
None
val_acc: 0.232323229313
val_loss: 3.88496732712
train_acc: 0.0965207634216
train_loss: 4.07161939425
train/val loss ratio: 1.04804469418
知道如何处理吗?
原文由 lmpeixoto 发布,翻译遵循 CC BY-SA 4.0 许可协议
使用我的 Keras (
2.0.6
) 和 Python (3.5.0
) 版本,这对我有用:这会将以下行输出到文件: