载入已有模型参数过程中,出现报错,代码及错误如下:
def load_params(path, params):
load parameters
pp = numpy.load(path)
for kk, vv in params.items():
if kk not in pp:
warnings.warn('%s is not in the archive'%kk)
continue
params[kk] = pp[kk]
return params
报错如下:在找这个错误的过程中,遇到一种解释是:
just remove your database downloaded at ur root folder. and run again. make sure ur connection, because this problem caused by the database you downloaded is failed.
原答案戳这里
这正是我们这里遇到的问题,当我们在下载模型的过程中出现异常,所下载的额模型是破损的,按照路径可以找到文件,但是无法正常载入。如果你是导入数据出现此错误,请移步补充。
解决办法就是删除破损文件,重新下载该文件,即可正常运行。
- 补充
另一种报这个错误的情况:
keras 实践中需要先导入数据集,如:
from keras.datasets import mnist
运行时可能也会出现 ‘NpzFile’ object has no attribute ‘zip’ 错误。导致这种情况的原因是上一次的数据集导入中途发生了中断,程序无法在这里恢复。
解决办法为:将下载失败的缓存文件删除,重新执行程序。
在Winodws下,这个文件夹为“C:\Users\Administrator.keras\datasets”
原文:https://blog.csdn.net/Kexiii/article/details/77099798