IniziaInizia gratis

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.

Questo esercizio fa parte del corso

Deep Learning for Images with PyTorch

Visualizza il corso

Istruzioni dell'esercizio

  • 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.

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

# Implement the RPN classification loss function
rpn_cls_criterion = ____

# Implement the RPN regression loss function
rpn_reg_criterion = ____

# Implement the R-CNN classification Loss function
rcnn_cls_criterion = ____

# Implement the R-CNN regression loss function
rcnn_reg_criterion = ____
Modifica ed esegui il codice