python - 保存 CNN 模型时出现“FileNotFoundError: [Errno 2] No such file or directory”
问题描述
我尝试将 CNN 模型和权重保存为 json 格式,但我在这里遇到了一些我不知道的问题
#save model and weight
#model to json files
model_json = model.to_json()
with open("model/model_json_sgd001.json", "w") as json_file:
json_file.write(model_json)
#weight to h5 file
model.save_weights("model/model_1_sgd001.h5")
print("Model dan Bobot telah disimpan")
错误说
> FileNotFoundError
> Traceback (most recent call last) <ipython-input-14-d1dce1f405b9> in <module>
> 2 #model to json files
> 3 model_json = model.to_json()
> ----> 4 with open("model/model_json_sgd001.json", "w") as json_file:
> 5 json_file.write(model_json)
> 6 #weight to h5 file
>
> FileNotFoundError: [Errno 2] No such file or directory:
> 'model/model_json_sgd001.json'
所以我只需要制作一个文件model_json_sgd001.json
?
解决方案
推荐阅读
- javascript - 如何将脚本标签注入标题?
- java - 在子类中继承产生空值
- android - 为什么 onFocusChangeListener 仅在单击顶部按钮时有效 - Android
- apache-camel - Camel - 基于消息的特定异常处理处理
- docker - 使用 Docker Compose 时无法使用 GitBash 执行到容器中
- vue.js - Vue.js 错误 6:1 错误 Prefer default export import/prefer-default-export
- java - 使用 Azure Devops 将自动化测试结果导入 Xray Cloud multipart
- excel - 在 IF 语句中包含多个条件的最有效方法
- python - 使用来自 scipy 的最小化函数最小化
- mysql - 外键约束“screenshot_ibfk_1”中的引用列“build_id”和引用列“build_id”不兼容