I downloaded the vgg16-notop pretrained weights,but when I want to load the weights it always show me:
KeyError: "Can't open attribute (Can't locate attribute: 'nb_layers')"
the environment is{ spyder+keras 2.0.6+tensorflow backend+python 3.5.2}
src here:
import h5py
weights_path = 'vgg16_weights_tf_dim_ordering_tf_kernels_notop.h5'
f = h5py.File(weights_path)
for k in range(f.attrs['nb_layers']):
if k >= len(model.layers):
we don't look at the last (fully-connected) layers in the savefile
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)
I downloaded the vgg16-notop pretrained weights,but when I want to load the weights it always show me: KeyError: "Can't open attribute (Can't locate attribute: 'nb_layers')" the environment is{ spyder+keras 2.0.6+tensorflow backend+python 3.5.2} src here:
import h5py weights_path = 'vgg16_weights_tf_dim_ordering_tf_kernels_notop.h5' f = h5py.File(weights_path) for k in range(f.attrs['nb_layers']): if k >= len(model.layers):
we don't look at the last (fully-connected) layers in the savefile
f.close() print('Model loaded.')