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: ‘layer_names’) #2

Open
shubhpy opened this issue Nov 23, 2017 · 1 comment

Comments

@shubhpy
Copy link

shubhpy commented Nov 23, 2017

model.load_weights("../face-comparer/experiments/weights/example_experiment.last.weights"")

Traceback (most recent call last):
  File "compare.py", line 40, in <module>
    compare(root + "bo1.jpg",root+"bo2.jpg")
  File "compare.py", line 13, in compare
    model.load_weights("../face-comparer/experiments/weights/example_experiment.last.weights"")
  File "/home/shubhanshu/ml-python/lib/python3.5/site-packages/keras/engine/topology.py", line 2622, in load_weights
    load_weights_from_hdf5_group(f, self.layers)
  File "/home/shubhanshu/ml-python/lib/python3.5/site-packages/keras/engine/topology.py", line 3103, in load_weights_from_hdf5_group
    layer_names = [n.decode('utf8') for n in f.attrs['layer_names']]
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "/home/shubhanshu/ml-python/lib/python3.5/site-packages/h5py/_hl/attrs.py", line 60, in __getitem__
    attr = h5a.open(self._id, self._e(name))
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "h5py/h5a.pyx", line 77, in h5py.h5a.open
KeyError: "Can't open attribute (can't locate attribute: 'layer_names')"

Above Bold line is throwing the above keyerror when example_experiments weights are used but with new weights, it worked.

Can someone please upload correct weights?
I do not have a "decent machine" to run all 1000*1000 epoch iterations

Thanks

@aleju
Copy link
Owner

aleju commented Nov 24, 2017

The Keras saving/loading functions have likely been changed since the weights file was created. Your options would be to downgrade Keras, try writing your own loading function that is backwards-compatible (not sure if possible) or rerun the training.

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