我有一个Python代码,使用Keras
。我没有发布代码,因为代码有点长,而且问题似乎与代码本身无关。
这是我遇到的错误:
File "h5py\h5a.pyx", line 77, in h5py.h5a.open (D:\Build\h5py\h5py-2.7.0\h5py\h5a.c:2350)
KeyError: "Can't open attribute (Can't locate attribute: 'nb_layers')"
可能是什么问题?和Keras有关系吗?我该如何解决这个问题?
EDIT 1
该错误似乎与这部分代码有关:
# load VGG16 weights
f = h5py.File(weights_path)
for k in range(f.attrs['nb_layers']):
if k >= len(model.layers):
break
g = f['layer_{}'.format(k)]
weights = [g['param_{}'.format(p)] for p in range(g.attrs['nb_params'])]
model.layers[k].set_weights(weights)
f.close()
print('Model loaded.')
Thanks.
使用权重文件 vgg16_weights_th_dim_ordering_th_kernels.h5https://github.com/fchollet/deep-learning-models/releases https://github.com/fchollet/deep-learning-models/releases
该文件采用 Keras 2 格式。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)