【发布时间】:2022-08-22 21:04:53
【问题描述】:
我的项目涉及细胞检测,所以我想我会尝试使用Usiigaci pre-trained weights 训练我的神经网络。
但是当我尝试时出现以下错误:
ValueError: Layer #362 (named \"anchors\") expects 1 weight(s), but the saved weights have 0 element(s)。
例如,对于预训练的 coco 重量,训练效果很好。
这是我用来加载权重的代码:
model = MaskRCNN(mode=\'training\', model_dir=\'./\', config=config) model.load_weights(\'Usiigaci_3.h5\', by_name=True, exclude=[\"mrcnn_class_logits\", \"mrcnn_bbox_fc\", \"mrcnn_bbox\", \"mrcnn_mask\"])
当我尝试加载通过在我自己的照片上训练我的模型生成的权重时,我也遇到了类似的问题,以继续我上次停止的训练。 收到的错误是:
ValueError: Layer #362 (named \"anchors\"), weight <tf.Variable \'Variable:0\' shape=(4, 261888, 4) dtype=float32> has shape (4, 261888, 4), but the saved weight has shape (2, 261888, 4).
加载重量:
model.load_weights(\'new_weigths/40_epochs/mask_rcnn_cell_cfg_0040.h5\', by_name=True, exclude=[\"mrcnn_class_logits\", \"mrcnn_bbox_fc\", \"mrcnn_bbox\", \"mrcnn_mask\"])
如果您了解为什么会这样,请告诉我。 谢谢!!
标签: python tensorflow neural-network recurrent-neural-network transfer-learning