Skip to content

loading weights error in the testing step, after a successful transfer learning training #64

@0xzhou

Description

@0xzhou

Hi, Thank you very much for the nice code and instructions.
I use your ResNet18 model as an image encoder in training a VAE. I can train with your ResNet18 model with the pretrained weights. But when I want to test the trained model by loading the saved weights, I got the following errors. Could you please give me some advice on fixing it?

Traceback (most recent call last): File "test_MMI.py", line 123, in <module> main(arg_parser.parse_test_arguments(sys.argv[1:])) File "test_MMI.py", line 62, in main model.load_weights(weights_path) File "/home/zmy/anaconda3/envs/tfk-3dvae/lib/python3.6/site-packages/tensorflow/python/keras/engine/network.py", line 1516, in load_weights saving.load_weights_from_hdf5_group(f, self.layers) File "/home/zmy/anaconda3/envs/tfk-3dvae/lib/python3.6/site-packages/tensorflow/python/keras/engine/saving.py", line 810, in load_weights_from_hdf5_group layer, weight_values, original_keras_version, original_backend) File "/home/zmy/anaconda3/envs/tfk-3dvae/lib/python3.6/site-packages/tensorflow/python/keras/engine/saving.py", line 468, in preprocess_weights_for_loading weights = convert_nested_model(weights) File "/home/zmy/anaconda3/envs/tfk-3dvae/lib/python3.6/site-packages/tensorflow/python/keras/engine/saving.py", line 444, in convert_nested_model original_backend=original_backend)) File "/home/zmy/anaconda3/envs/tfk-3dvae/lib/python3.6/site-packages/tensorflow/python/keras/engine/saving.py", line 468, in preprocess_weights_for_loading weights = convert_nested_model(weights) File "/home/zmy/anaconda3/envs/tfk-3dvae/lib/python3.6/site-packages/tensorflow/python/keras/engine/saving.py", line 456, in convert_nested_model original_backend=original_backend)) File "/home/zmy/anaconda3/envs/tfk-3dvae/lib/python3.6/site-packages/tensorflow/python/keras/engine/saving.py", line 468, in preprocess_weights_for_loading weights = convert_nested_model(weights) File "/home/zmy/anaconda3/envs/tfk-3dvae/lib/python3.6/site-packages/tensorflow/python/keras/engine/saving.py", line 444, in convert_nested_model original_backend=original_backend)) File "/home/zmy/anaconda3/envs/tfk-3dvae/lib/python3.6/site-packages/tensorflow/python/keras/engine/saving.py", line 549, in preprocess_weights_for_loading if K.int_shape(layer.weights[0]) != weights[0].shape: IndexError: list index out of range

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions