Automatic-Signature-Verification icon indicating copy to clipboard operation
Automatic-Signature-Verification copied to clipboard

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

Open pique-b opened this issue 1 year ago • 0 comments

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.

pique-b avatar Apr 29 '24 03:04 pique-b