Git Product home page Git Product logo

Comments (3)

scaelles avatar scaelles commented on July 16, 2024

Hello,

Thanks for your interest! Since we are predicting masks after cropping the image using the extreme points, there will be an imbalance on the number of foreground and background pixels. There will be way more foreground pixels than background ones which can bias the network on being overconfident about foreground. In order to alleviate that problem, we use the class balancing that was originally introduced in [1].

[1]: Holistically-Nested Edge Detection

from dextr-pytorch.

mt-cly avatar mt-cly commented on July 16, 2024

Hi, thanks for your reply.
I read the reference paper, the paper introduces a bias weight to two terms in the formula, which corresponds to your num_labels_neg/num_total and num_labels_pos/num_total. But it still exists a gap with your implementation. I am not so clear about the loss_val calculation.
following is copied from your code.

output_gt_zero = torch.ge(output, 0).float()
loss_val = torch.mul(output, (labels - output_gt_zero)) - torch.log(1 + torch.exp(output - 2 * torch.mul(output, output_gt_zero)))

I wonder why it is not as follows:
loss_val = torch.mul(label, torch.log(1/(1+torch.exp(-output)))) + torch.mul(1.-label, torch.log(1-1/(1+torch.exp(-output))))
Thank you.

from dextr-pytorch.

scaelles avatar scaelles commented on July 16, 2024

Hello,

The loss that you describe would be the theoretical definition (you can find it here in one of our previous projects). However, that can be unstable during training and the formulation is rearranged so it behaves better during training. You can find here a similar derivation from the theoretical to the practical one (it's not exactly the same, but you should be able to derive ours from there).

Also, note also that the actual class balancing happens here.

Let me know if you have any other question!

from dextr-pytorch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.