Skip to content

我call完之后还是不能假装模型啊 #9

@wlz987

Description

@wlz987

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions