Giter Site home page Giter Site logo

Comments (5)

TFboys-lzz avatar TFboys-lzz commented on May 27, 2024

Thank you for your interest in our work!
I check the code released and make sure that the operations {division, log, and sqrt} have added an eps.
But, You can try to clamp the input of the POW operation to a range greater than 0, i.e., sine = torch.sqrt((1.0 - torch.pow(cosine.(0.0,1.0), 2)).clamp(0.0001, 1.0)) in 152 lines of utils.py, because torch.pow(a) = nan when a < 0.
If the above operation cannot address your problem, you can try to use the torch.nn.utils.clip_grad_norm_ operation to clip gradient norm of an iterable of parameters.
If the above suggestions solve your problem, I hope you can let me know so that I can update the code, thanks!!

from mpscl.

TFboys-lzz avatar TFboys-lzz commented on May 27, 2024

Alternatively, you can try clamping the input of torch.sqrt() to a larger scale, e.g., sine = torch.sqrt((1.0 - torch.pow(cosine.(0.0,1.0), 2)).clamp(0.1, 1.0)).
Because, the grad of torch.sqrt 1/torch.sqrt(x), if x = 0.0001, the grad = 10000

from mpscl.

William4553 avatar William4553 commented on May 27, 2024

Thanks for the response and for the advice. I found that line 35 of loss.py is causing my problem. When I removed the weight parameter from loss = F.cross_entropy(input=pred,target=label,weight=weight), I no longer got the issue with nan. But when the weight parameter is there, loss has the value nan.

from mpscl.

TFboys-lzz avatar TFboys-lzz commented on May 27, 2024

Thanks for your reply!
I will check the code again.

from mpscl.

TFboys-lzz avatar TFboys-lzz commented on May 27, 2024

Thanks to Feng Wei from Zhejiang University. We found that the instability of the training may be due to the exceptionally small (close to zero) weights of the background classes.

from mpscl.

Related Issues (13)

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.