WeidiXie / VGG-Speaker-Recognition

Utterance-level Aggregation For Speaker Recognition In The Wild
363 stars 97 forks source link

Error in loading the pretrained weights #34

Closed aliakbar09a closed 5 years ago

aliakbar09a commented 5 years ago

When loading the pretrained model, I am getting the following error:

Traceback (most recent call last):
  File "main.py", line 201, in <module>
    main()
  File "main.py", line 82, in main
    if mgpu == 1: network.load_weights(os.path.join(args.resume))
  File "/home/ultron/miniconda3/envs/tf/lib/python3.7/site-packages/keras/engine/network.py", line 1166, in load_weights
    f, self.layers, reshape=reshape)
  File "/home/ultron/miniconda3/envs/tf/lib/python3.7/site-packages/keras/engine/saving.py", line 1030, in load_weights_from_hdf5_group
    str(len(filtered_layers)) + ' layers.')
ValueError: You are trying to load a weight file containing 80 layers into a model with 81 layers.
WeidiXie commented 5 years ago

are you testing the model ? are trying to initialise another one with pre-trained weights ?

aliakbar09a commented 5 years ago

I am trying to initialise another one with pre-trained weights.

WeidiXie commented 5 years ago

then, simply use network.load_weights(os.path.join(args.resume), skip_mismatch=True)

You are adding another classifier at the end, which the model can not find the corresponding weights for that layer.

mazimiucc commented 3 years ago

File "new1.py", line 46, in network_eval.load_weights("./model1/weights.h5", by_name=True, skip_mismatch=True) File "C:\Users\HP\AppData\Local\Programs\Python\Python36\lib\site-packages\keras\engine\network.py", line 1163, in load_weights reshape=reshape) File "C:\Users\HP\AppData\Local\Programs\Python\Python36\lib\site-packages\keras\engine\saving.py", line 1083, in load_weights_from_hdf5_group_by_name original_keras_version = f.attrs['keras_version'].decode('utf8') AttributeError: 'str' object has no attribute 'decode'

mazimiucc commented 3 years ago

https://github.com/keras-team/keras/issues/14265