Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Azure by (5.8k points)

For my thesis, I am trying to modify the loss function of faster-rcnn with regards to recognizing table structures.

Currently, I am using Facebook's Detectron. It seems to be working great but I am now actively trying to modify the loss function. Debugging my code I notice this is where the loss functions are added fast_rcnn_heads.py:75:

def add_fast_rcnn_losses(model):

"""Add losses for RoI classification and bounding box regression."""

cls_prob, loss_cls = model.net.SoftmaxWithLoss(

    ['cls_score', 'labels_int32'], ['cls_prob', 'loss_cls'],

    scale=model.GetLossScale()

)

loss_bbox = model.net.SmoothL1Loss(

    [

        'bbox_pred', 'bbox_targets', 'bbox_inside_weights',

        'bbox_outside_weights'

    ],

    'loss_bbox',

    scale=model.GetLossScale()

)

loss_gradients = blob_utils.get_loss_gradients(model, [loss_cls, loss_bbox])

model.Accuracy(['cls_prob', 'labels_int32'], 'accuracy_cls')

model.AddLosses(['loss_cls', 'loss_bbox'])

model.AddMetrics('accuracy_cls')

return loss_gradients

The debugger cant find any declaration or implementation of mode.net.SmoothL1Loss nor SoftmaxWithLoss. Detectron uses caffe, and when I look in the net_builder (which inits the model.net) I see it makes "binds"(don't know the proper word) to caffe2, which in itself is a py lib with a compiled lib behind it.

Am I looking in the wrong place to make a minor adjustment to this loss function, or will I really have to open de source from dcaffe, adjust the loss, recompile the lib?

1 Answer

0 votes
by (9.6k points)

Try to implement the function by yourself. 

You can create a python function to predict and return loss value. Caffe is now part of PyTorch.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...