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

Getting ValueError: New layer sequential_1 expects 20 weights, but the saved weights have 12 elements. #4

Open
pique-b opened this issue Apr 29, 2024 · 0 comments

Comments

@pique-b
Copy link

pique-b commented Apr 29, 2024

I have tried the example on Google Colab to generate the model. I then tried to run the test using a saved file (.h5) on my local machine.

However I keep getting the following error:

ValueError: Layer #0 (named "sequential_1" in the current model) was found to correspond to layer sequential_1 in the save file. However the new layer sequential_1 expects 20 weights, but the saved weights have 12 elements.

I tried to run through the related portion of the codes but really failed to identify where the error was generating from.

The full traceback is:

Traceback (most recent call last):
File "./run_cedar.py", line 545, in
acc_thresh.append(load_and_check_model('./Weights/signet-cedar-full-xavier-001.h5'))
File "./run_cedar.py", line 518, in load_and_check_model
model.load_weights(weight)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/keras/_impl/keras/engine/topology.py", line 1107, in load_weights
load_weights_from_hdf5_group(f, self.layers)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/keras/_impl/keras/engine/topology.py", line 1514, in load_weights_from_hdf5_group
str(len(weight_values)) + ' elements.')
ValueError: Layer #0 (named "sequential_1" in the current model) was found to correspond to layer sequential_1 in the save file. However the new layer sequential_1 expects 20 weights, but the saved weights have 12 elements.

Could you guide me as to where the error might be coming from?

PS. Another thing that I came across was that after the end of the epoch 6 (run on Colab), the loss was coming to nan.

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

1 participant