Hello.
I trained FasterRCNN model on my problem to a certain extent.
Now I’d like to set model to evaluation mode (model.eval()) to disable some specific layers (like dropout) but I still want to get loss on my data.
If I set model.eval() then I get detection but not losses while if I set model.train() my loss is different every run on the same sample and I dont’t get detections.
Can I do it without modifying the module source code?
I see such training conditions in FasterRCNN submodules:
losses = {}
if self.training:
    assert targets is not None
    labels, matched_gt_boxes = self.assign_targets_to_anchors(anchors, targets)
    regression_targets = self.box_coder.encode(matched_gt_boxes, anchors)
    loss_objectness, loss_rpn_box_reg = self.compute_loss(
        objectness, pred_bbox_deltas, labels, regression_targets)
    losses = {
        "loss_objectness": loss_objectness,
        "loss_rpn_box_reg": loss_rpn_box_reg,
    }
return boxes, losses

[rpn.py - forward()]