GithubHelp home page GithubHelp logo

Loss is 'Nan' about anchorloss HOT 9 CLOSED

slryou41 avatar slryou41 commented on September 24, 2024
Loss is 'Nan'

from anchorloss.

Comments (9)

slryou41 avatar slryou41 commented on September 24, 2024

Thanks for your interest! How many classes are you using? It looks like the loss is not decreasing even when you are using warmup, which is trained with the standard cross entropy. Were you able to train with cross entropy?

from anchorloss.

murdockhou avatar murdockhou commented on September 24, 2024

Hi, 3 classes in dataset. I can trained well with cross entropy. When I use cross entropy, the first several epochs maybe also learning nothing but with training process going, the network will learned something finally. So, it's worked with cross entropy but not worked with anchor loss by using same hyper parameters.

from anchorloss.

slryou41 avatar slryou41 commented on September 24, 2024

This loss picks the prediction value from the target label and modulates the loss values for the other classes, so it might fluctuate when trained with 3 classes at the beginning. I still don't understand why it goes to NaN... Do you mind adding (1-pt).clamp(min=1e-10) in line 70 to make sure the loss never sees log(0)?

from anchorloss.

murdockhou avatar murdockhou commented on September 24, 2024

No useful. I'm so sad. I trained model with crossentropy or bce all okay, only change the loss to AnchorLoss, after several epochs, got nan.......

from anchorloss.

slryou41 avatar slryou41 commented on September 24, 2024

I guess the only reason why it goes to NaN is from log(0). Did you apply softmax or sigmoid before passing the output value to the loss function? This loss function assumes that the output is not normalized.

from anchorloss.

murdockhou avatar murdockhou commented on September 24, 2024

@slryou41 No, only used original output from model, not normalized. The weired is the corss entropy or bce loss is okay but anchor loss not. So I don't think that there exists error about model's output.

from anchorloss.

slryou41 avatar slryou41 commented on September 24, 2024

As a sanity check, can you set gamma = 0 and see if it goes to NaN?

from anchorloss.

murdockhou avatar murdockhou commented on September 24, 2024

Useless. Meet NaN same. I gave up this try...

from anchorloss.

jongli747 avatar jongli747 commented on September 24, 2024

@slryou41 Hi. thanks for sharing your awesome work. I am trying to incorporate this loss in my project. I am facing the same "nan" problem after few epoch. I have followed everything you told earlier in this issue. But nothing works for me. so I am working on binary classification and output prediction is observed from the max operation. Please tell me what to do to get the work done.

from anchorloss.

Related Issues (8)

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.