-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
ValueError: Unable to load weights saved in HDF5 format into a subclassed Model which has not created its variables yet. Call the Model first, then load the weights.
my_model = FasterRCNNTrainer(FasterRCNN(21, (7, 7)))
# 相当于build一下模型
img, bboxes, labels, scale = dataset[1]
bboxes_ = tf.cast(bboxes, dtype=tf.float32)
labels_ = tf.cast(labels, dtype=tf.float32)
rpn_loc_loss, rpn_cls_loss, roi_loc_loss, roi_cls_loss = my_model.__call__(img, bboxes_, labels_, scale)
print([rpn_loc_loss, rpn_cls_loss, roi_loc_loss, roi_cls_loss])
# 然后就能载入权重了
my_model.load_weights('frcnn.h5')
Metadata
Metadata
Assignees
Labels
No labels