problem description
I used Keras to build a neural network that can be trained or saved with model.save ("model.h5"), but when I load the model with model = load_model ("model.h5"), I get the following error:
Traceback (most recent call last):
File "C:/programming/pycharm/cnn_attention_lstm/cnn_attention_lstm/train7.py", line 31, in
main()
File "C:/programming/pycharm/cnn_attention_lstm/cnn_attention_lstm/train7.py", line 23, in main
history = classifier.fit(data_dir_path=input_dir_path, model_dir_path=output_dir_path, data_set_name=data_set_name)
File "C:\programming\pycharm\cnn_attention_lstm\cnn_attention_lstm\model7again.py", line 113, in fit
model = self.create_model()
File "C:\programming\pycharm\cnn_attention_lstm\cnn_attention_lstm\model7again.py", line 66, in create_model
model = load_model("model.h5")
File "C:\Users\tong\AppData\Local\Programs\Python\Python36\Lib\site-packages\keras\engine\saving.py", line 263, in load_model
load_weights_from_hdf5_group(f["model_weights"], model.layers)
File "C:\Users\tong\AppData\Local\Programs\Python\Python36\Lib\site-packages\keras\engine\saving.py", line 915, in load_weights_from_hdf5_group
reshape=reshape)
File "C:\Users\tong\AppData\Local\Programs\Python\Python36\Lib\site-packages\keras\engine\saving.py", line 554, in preprocess_weights_for_loading
weights = convert_nested_time_distributed(weights)
File "C:\Users\tong\AppData\Local\Programs\Python\Python36\Lib\site-packages\keras\engine\saving.py", line 513, in convert_nested_time_distributed
layer.layer, weights, original_keras_version, original_backend)
File "C:\Users\tong\AppData\Local\Programs\Python\Python36\Lib\site-packages\keras\engine\saving.py", line 556, in preprocess_weights_for_loading
weights = convert_nested_model(weights)
File "C:\Users\tong\AppData\Local\Programs\Python\Python36\Lib\site-packages\keras\engine\saving.py", line 532, in convert_nested_model
original_backend=original_backend))
File "C:\Users\tong\AppData\Local\Programs\Python\Python36\Lib\site-packages\keras\engine\saving.py", line 556, in preprocess_weights_for_loading
weights = convert_nested_model(weights)
File "C:\Users\tong\AppData\Local\Programs\Python\Python36\Lib\site-packages\keras\engine\saving.py", line 544, in convert_nested_model
original_backend=original_backend))
File "C:\Users\tong\AppData\Local\Programs\Python\Python36\Lib\site-packages\keras\engine\saving.py", line 673, in preprocess_weights_for_loading
elif layer_weights_shape != weights[0].shape:
IndexError: list index out of range
Process finished with exit code 1