简体   繁体   English

更快地修改损失函数RCNN Detectron

[英]Modifying loss function faster rcnn detectron

For my thesis I am trying to modify the loss function of faster-rcnn with regards to recognizing table structures. 就我的论文而言,我试图在识别表结构方面修改faster-rcnn的损失函数。

Currently I am using Facebooks Detectron. 目前,我正在使用Facebook Detectron。 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 : 调试我的代码,我注意到这是在其中添加损失函数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. 调试器找不到mode.net.SmoothL1Loss或SoftmaxWithLoss的任何声明或实现。 Detectron uses caffe, and when I look in the net_builder (which inits the model.net) I see it makes "binds"(dont know the proper word) to caffe2, which on itself is a pylib with a compiled lib behind it. Detectron使用caffe,当我查看net_builder(用于启动model.net的文件)时,我发现它对caffe2产生了“绑定”(不知道正确的词),而caffe2本身就是一个pylib,后面带有编译的lib。

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? 我是在错误的地方找这个损失函数做些小调整,还是真的需要从dcaffe打开源代码,调整损失,重新编译lib?

Greets, 映入眼帘,

You should implement loss function by yourself. 您应该自己实现损失功能。 Modifying library source code and recompile it - isn't very good idea :) 修改库源代码并重新编译-不是一个好主意:)

You can create python function, that will take GT and predicted data and return loss value. 您可以创建python函数,该函数将获取GT和预测数据并返回损失值。

Also you can create a duplicate of L1-smooth or Cross-entropy, which is currently used and then, when you will make sure, that they are the same, you can modify them. 您还可以创建当前使用的L1平滑或交叉熵的副本,然后在确保它们相同的情况下,可以对其进行修改。 Or you can implement, for example, L2 loss for boxes and use it instead. 或者,您可以实现例如对箱子的L2损失,而改用它。

More information about custom losses you can find in caffee documentation. 您可以在caffee文档中找到有关自定义损失的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 pytorch Faster-RCNN 的验证损失 - Validation loss for pytorch Faster-RCNN 了解更快的rcnn - Understanding Faster rcnn 在自定义Keras损失函数中修改张量 - Modifying the tensor in a custom Keras loss function (ResNet50, VGG16, etc..) 和 (RCNN, Faster RCNN, etc..) 有什么区别? - What is the difference between (ResNet50, VGG16, etc..) and (RCNN, Faster RCNN, etc..)? Tensorflow对象检测API Faster-RCNN收敛但检测不准确 - Tensorflow Object Detection API Faster-RCNN converges but detection is innacurate 无法在我的自定义数据集中训练更快的 rcnn model - Can't train faster rcnn model in my custom dataset Faster-RCNN,我们为什么不只使用RPN进行检测? - Faster-RCNN, why don't we just use only RPN for detection? Tensorflow更快的rcnn提供了良好的检测能力,但仍然可以检测到可可物体的误报 - Tensorflow faster rcnn giving good detection but still detecting false positives with coco objects 如何在使用更快的 rcnn/ssd 模型的同时加速对象检测 - How to speed up object detection while using faster rcnn/ ssd models 为什么如此低的预测率25 - 40 [sec / 1]使用更快的RCNN在GPU上进行自定义对象检测? - Why so low Prediction Rate 25 - 40 [sec/1] using Faster RCNN for custom object detection on GPU?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM