Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError: "Can't open attribute (Can't locate attribute: 'nb_layers')" #16

Closed
rockywind opened this issue Jan 22, 2018 · 1 comment
Closed

Comments

@rockywind
Copy link

import h5py
import os
import numpy as np

def loadWeightsPartial( model , weights_path , n_layers ):
# f=h5py.File(weights_path,mode="r")
# k=f.attrs['layer_names']['block1_conv1']
# weigh
f = h5py.File(weights_path)
for k in range(f.attrs['nb_layers']):
# for k in range(f.attrs['layer_names']):
if k >= n_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()

When I call this function,it showed this error.
I don't know how to handle it,please!

@divamgupta
Copy link
Owner

Image segmentation keras has been updated. The new version should fix the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants