keras - 无法在 Modelcheckpoint 中创建文件和使用文件路径
问题描述
我在这里关注这个超级好的教程https://dashee87.github.io/data%20science/deep%20learning/python/another-keras-tutorial-for-neural-network-beginners/。
但是,我无法正确使用 Modelcheckpoint 中的文件路径。
filepath="C:/Users/Thomas01/Documents/pimaindiansdiabetescsv/nnweights-
{epoch:02d}.hdf5"
checkpoint = keras.callbacks.ModelCheckpoint(filepath, monitor='val_acc',
verbose=0, save_weights_only=False, save_best_only=False, mode='max')
[...]
temp_test_model.load_weights("C:/Users/Thomas01/Documents/pimaindiansdiabetescsv/nnweights-%02d.hdf5" % i)
[...]
我得到:
OSError:无法打开文件(无法打开文件:名称 = 'C:/Users/Thomas01/Documents/pimaindiansdiabetescsv/nnweights-00.hdf5',errno = 2,错误消息 = '没有这样的文件或目录',标志 = 0, o_flags = 0)
尝试使用原始字符串(但我认为我丢失了参数说明符?),或 \,但没有一个工作。
解决方案
设置verbose=1
看看它保存在哪里
checkpoint = keras.callbacks.ModelCheckpoint(filepath, monitor='val_acc', verbose=1, save_weights_only=False, save_best_only=False, mode='max')
# Epoch 00001: val_acc improved from -inf to 0.53781, saving model to /yourpath/yourpath
推荐阅读
- java - 如何使用 JPA 和 Hibernate 为关联的只读实体获取单个实例?
- malware - Clamav 逻辑签名生成
- javascript - 带有条件的箭头函数不返回数组的所有元素
- python - LDAP Python - 搜索作为嵌套 OU 中组成员的用户
- sql - SQL Server:与另一个数据库的外键关系:最佳方法
- scala - Spark Dataframe 上的 val 与 def 性能
- html - 让 div 元素“认为”屏幕具有一定宽度?
- docker - 无法在 Hyperledger First Network 设置中将节点加入通道
- java - 非完美迷宫生成
- python-3.x - 比较不同模型的准确性