MulaiMulai sekarang secara 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.

Latihan ini adalah bagian dari kursus

Deep Learning for Images with PyTorch

Lihat Kursus

Petunjuk latihan

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

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# 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 = ____
Edit dan Jalankan Kode