Giter VIP home page Giter VIP logo

Comments (9)

ppwwyyxx avatar ppwwyyxx commented on July 18, 2024 1

I was not clear. By "iteration", I mean the iteration of the outer for-loop in the code I posted.
Since the counters were not reset between these iterations, each image in a batch ends up using a different beta, which is neither the neg/pos ratio within a batch, nor a neg/pos ratio within an image.

from hed.

s9xie avatar s9xie commented on July 18, 2024

The accumulation iters through all spatial locations in one SINGLE image. The counter resets everytime the forward function is called. The balancing factor we used is not precomputed across the whole dataset (for which it could be), but on a single image instead.

from hed.

s9xie avatar s9xie commented on July 18, 2024

Oooops. Thanks for the heads-up. You are correct. This is a bug. Luckily it doesn't affect the results: because it is in the forward loop only for "showing" the loss. And the (wrongly) computed balancing factor, should still be around 0.05vs0.95, similar to what is computed globally, or on a single image.

The crucial backward computation is correct.

Thanks again for noticing this... I'll correct it right away.

from hed.

lexie0212 avatar lexie0212 commented on July 18, 2024

quick question on the backward computation: on line 107:
bottom_diff[i * dim + j] *= 1 * count_neg / (count_pos + count_neg);

and line 110
bottom_diff[i * dim + j] *= count_pos / (count_pos + count_neg);

why there is an extra "1" in line 107? It looked like doesn't make any differences between these two lines while only bottom_diff is weighted based on the count of labels?

from hed.

ppwwyyxx avatar ppwwyyxx commented on July 18, 2024

Yes. You can remove the "1" and it's obviously equivalent.

from hed.

brisker avatar brisker commented on July 18, 2024

@ppwwyyxx
@lexie0212

Hi, the modified SigmoidCrossEntropy Loss layer has a line
that reads like -:

bottom_diff[i * dim + j] *= 1 * count_neg / (count_pos + count_neg);

It seems that the gradients are multiplied every iteration in the loops. It is a little confusing to me. Why there is a '*' ahead of the '=' ?

from hed.

ppwwyyxx avatar ppwwyyxx commented on July 18, 2024

That's back propagation.

from hed.

brisker avatar brisker commented on July 18, 2024

@ppwwyyxx
The loss may be something like:
image
So you mean the gradients calculation is automatically done by caffe, here in the code , the author is just multiplying the gradients by the weight factor?

from hed.

ppwwyyxx avatar ppwwyyxx commented on July 18, 2024

It's done in the code. https://github.com/s9xie/hed/blob/master/src/caffe/layers/sigmoid_cross_entropy_loss_layer.cpp#L89

from hed.

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.