Open ZhiyuanChen opened 5 years ago
I get the same error ValueError: Layer #389 (named "mrcnn_bbox_fc"), weight <tf.Variable 'mrcnn_bbox_fc/kernel:0' shape=(1024, 8) dtype=float32> has shape (1024, 8), but the saved weight has shape (1024, 324).
when I try to run the nucleus example with the mask_rcnn_coco.h5
from Release 2.0.
Edit: I found the solution to this problem here: https://github.com/matterport/Mask_RCNN/issues/849#issuecomment-432177985
@zhaoyucong I had the same problem. After searching for a while I found that when you want to fine-tune, you have to specify in "load_weights()" the parameter "by_name=True" in order to be able to use only some common layers (https://keras.io/models/about-keras-models/).
In my case that was not enough, and I added the following: model.load_weights(filepath, by_name=True, exclude=[ "mrcnn_class_logits", "mrcnn_bbox_fc", "mrcnn_bbox", "mrcnn_mask"])
Hope it helps
It took me a long time to figure out why my code does not work with error
ValueError: Layer #389 (named "mrcnn_bbox_fc"), weight <tf.Variable 'mrcnn_bbox_fc/kernel:0' shape=(1024, 8) dtype=float32_ref> has shape (1024, 8), but the saved weight has shape (1024, 324).
The pretrained weights 2.1 have a value of 2 in number of class meanwhile 2.0 have a value of 81.
exclude= "mrcnn_class_logits", "mrcnn_bbox_fc", "mrcnn_bbox", "mrcnn_mask" does not help as it's just simply ignore those layers and if you try this on the demo.ipynb, you can easily find there is nothing right about the result.
Please USE 2.0 INSTEAD to avoid above issue. https://github.com/matterport/Mask_RCNN/releases/download/v2.0/mask_rcnn_coco.h5