加载自己保存训练模型OSError: Unable to open file (unable to open file: name = ‘./model/LeNet_model‘, errno = 2

博主在复现LeNet网络训练后尝试保存并加载模型,遇到OSError提示文件未找到。尝试使用tf.saved_model加载模型,但发现model缺少evaluate方法。使用tf.keras.metrics.SparseCategoricalAccuracy()进行评估,并注意到Sequential和Model子类化构建的模型在预测上有差异。
摘要由CSDN通过智能技术生成

加载自定义模型出错

昨天,我在复现LeNet网络,训练都没有什么问题,我觉得可以保存模型,可就是在读取出现了错误。
保存:

model.save_weights('./model/LeNet_model')

生成文件:
在这里插入图片描述
读取:

model=load_model('./model/LeNet_model')

错误显示:

Traceback (most recent call last):
  File "D:/py_project/open_cv/LeNet.py", line 34, in <module>
    model=load_model('./model/LeNet_model')
  File "D:\py_project\venv\lib\site-packages\keras\engine\saving.py", line 492, in load_wrapper
    return load_function(*args, **kwargs)
  File "D:\py_project\venv\lib\site-packages\keras\engine\saving.py", line 583, in load_model
    with H5Dict(filepath, mode='r') as h5dict:
  File "D:\py_project\venv\lib\site-pac
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值