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

Time_distributed_1 layer error #83

Open
helenabdr opened this issue May 3, 2021 · 1 comment
Open

Time_distributed_1 layer error #83

helenabdr opened this issue May 3, 2021 · 1 comment

Comments

@helenabdr
Copy link

Hi guys!

I get this error when I load the weights of a trained model with VGG19 as the base network. Does anyone have any ideas/suggestions about this? I would appreciate it very much.

Traceback (most recent call last): File "main.py", line 63, in <module> model_rpn, model_classifier = get_models(C, common_path, class_mapping) File "/home/helena/Documents/LAR_Celesc/robocelesc_backend/src/utils/model.py", line 76, in get_models model_classifier.load_weights(os.path.join(common_path, 'vgg19_3classes_test_with_no_param_var_classifier_weights.h5'), by_name=True) File "/home/helena/Documents/LAR_Celesc/robocelesc_backend/env/lib/python3.7/site-packages/keras/engine/saving.py", line 492, in load_wrapper return load_function(*args, **kwargs) File "/home/helena/Documents/LAR_Celesc/robocelesc_backend/env/lib/python3.7/site-packages/keras/engine/network.py", line 1227, in load_weights reshape=reshape) File "/home/helena/Documents/LAR_Celesc/robocelesc_backend/env/lib/python3.7/site-packages/keras/engine/saving.py", line 1309, in load_weights_from_hdf5_group_by_name ' element(s).') ValueError: Layer #40 (named "time_distributed_1") expects 0 weight(s), but the saved weights have 2 element(s).

The code is:

`input_shape_img = (None, None, 3)

img_input = Input(shape=input_shape_img)
roi_input = Input(shape=(C.num_rois, 4))
#feature_map_input = Input(shape=input_shape_features) 

shared_layers = nn.nn_base(img_input, trainable=False)

rpn_layers = nn.rpn(shared_layers, num_anchors)
classifier = nn.classifier(shared_layers, roi_input, C.num_rois, nb_classes=len(C.class_mapping), trainable=False)

# instantiate models
model_rpn = Model(img_input, rpn_layers)
model_classifier = Model([img_input, roi_input], classifier)

# load weights
model_rpn.load_weights(os.path.join(common_path, 'vgg19_3classes_test_with_no_param_var_rpn_weights.h5'), by_name=True)
model_classifier.load_weights(os.path.join(common_path, 'vgg19_3classes_test_with_no_param_var_classifier_weights.h5'), by_name=True)`

Regards, Helena.

@helenabdr helenabdr changed the title time_distributed_1 layer error Time_distributed_1 layer error May 3, 2021
@AlOo2002
Copy link

AlOo2002 commented May 6, 2021

i think that after saving the config you change something in the code. delete everything u saved and then start over again

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

2 participants