Mask_RCNN icon indicating copy to clipboard operation
Mask_RCNN copied to clipboard

ValueError: Layer #389 (named "mrcnn_bbox_fc"), weight <tf.Variable 'mrcnn_bbox_fc/kernel:0' shape=(1024, 40) dtype=float32> has shape (1024, 40), but the saved weight has shape (1024, 324)

Open yaoliu0803 opened this issue 3 years ago • 0 comments

I had this problem in google colab tensorflow==2.4.1 kera==2.4.3

if init_with == "imagenet": model.load_weights(model.get_imagenet_weights(), by_name=True) elif init_with == "coco":

Load weights trained on MS COCO, but skip layers that

are different due to the different number of classes

See README for instructions to download the COCO weights

model.load_weights(COCO_MODEL_PATH, by_name=True, exclude=["mrcnn_class_logits", "mrcnn_bbox_fc", "mrcnn_bbox", "mrcnn_mask"]) elif init_with == "last":

Load the last model you trained and continue training

model.load_weights(model.find_last(), by_name=True)

mistake: ValueError Traceback (most recent call last) in 17 #加载预训练模型的权重 18 model.load_weights(COCO_MODEL_PATH, by_name=True, ---> 19 exclude=["mrcnn_class_logits","mrcnn_bbox_fc","mrcnn_bbox", "mrcnn_mask"]) 20 elif init_with == "last": 21 # Load the last model you trained and continue training

786                                symbolic_weights[i])) +
787                            ', but the saved weight has shape ' +

--> 788 str(weight_values[i].shape) + '.') 789 790 else:

ValueError: Layer #389 (named "mrcnn_bbox_fc"), weight <tf.Variable 'mrcnn_bbox_fc/kernel:0' shape=(1024, 40) dtype=float32> has shape (1024, 40), but the saved weight has shape (1024, 324).

Please anybody can help me.

yaoliu0803 avatar Sep 01 '22 00:09 yaoliu0803