1. Learn
  2. /
  3. Courses
  4. /
  5. Deep Learning for Images with PyTorch

Connected

Exercise

Define losses for RPN and R-CNN

You are planning to train an object detection model that utilizes both the RPN and R-CNN components. To be able to train it, you will need to define the loss function for each component.

You remember that the RPN component classifies whether a region contains an object and predicts the bounding box coordinates for the proposed regions.The R-CNN component classifies the object into one of multiple classes while also predicting the final bounding box coordinates.

torch, torch.nn as nn have been imported.

Instructions

100 XP
  • Define the RPN classification loss function and assign it to rpn_cls_criterion.
  • Define the RPN regression loss function and assign it to rpn_reg_criterion.
  • Define the R-CNN classification loss function and assign it to rcnn_cls_criterion.
  • Define the R-CNN regression loss function using and assign it to rcnn_reg_criterion.