Code Monkey home page Code Monkey logo

Comments (17)

cjt222 avatar cjt222 commented on September 24, 2024 1

Good idea! I try to clip ctc loss and not clip gradient, loss may converge now
image

from focal-ctc-omr.

jimitshah77 avatar jimitshah77 commented on September 24, 2024

Problem: After few step Loss explodes and than in the later epochs it produces 'Nan' as loss output.
It is suffering from exploding gradients problem!
Solution: Gradient Clipping!

from focal-ctc-omr.

jimitshah77 avatar jimitshah77 commented on September 24, 2024

Try this and tell me if the problem is reoccurring

Gradient Clipping:

Apply: tf.clip_by_value(clipping_variable,1e-10,1.0)
logits=tf.clip_by_value(logits,1e-10,1.0)

from focal-ctc-omr.

cjt222 avatar cjt222 commented on September 24, 2024

Thanks for your help, loss explodes problem is solved after add Gradient Clipping, but loss may not converge

from focal-ctc-omr.

jimitshah77 avatar jimitshah77 commented on September 24, 2024

Try different Learning rates and alpha, gamma values

from focal-ctc-omr.

cjt222 avatar cjt222 commented on September 24, 2024

I change some learning rates and alpha, gamma values and it not work. And i print p and ctc_loss ,p is always 0 and ctc_loss is always same, but when i set gamma to 0, ctc_loss becomes normal.
image

from focal-ctc-omr.

jimitshah77 avatar jimitshah77 commented on September 24, 2024

Try:
logits=tf.clip_by_value(logits,1e-7,1.0-1e-7)
or clipping is required near power function in the line where it calculates gamma

from focal-ctc-omr.

cjt222 avatar cjt222 commented on September 24, 2024

maybe clip as below is ok,ctc loss is not always same, but it is still not converge
image

from focal-ctc-omr.

jimitshah77 avatar jimitshah77 commented on September 24, 2024

What about p values? Are they still zero?
If they are still zero then try different function to calculate exp().

from focal-ctc-omr.

cjt222 avatar cjt222 commented on September 24, 2024

most of it is zeros and some of it may be 1e-37,i have try tf.math.exp() instead of tf.exp, result is same and not converge

from focal-ctc-omr.

jimitshah77 avatar jimitshah77 commented on September 24, 2024

Upper Limit of clipping would be an issue.
As the values are very small in p there might be issue in upper limit of clipping.
Try printing values of p without clipping.
Then deduce which range of values would be good for clipping.
Once you get values of p in some appropriate range (and not 0 or very small number) after applying clipping, it should converge.

from focal-ctc-omr.

cjt222 avatar cjt222 commented on September 24, 2024

In fact, loss becomes nan when p values is still zeros without clipping, so I can not get values of appropriate range

from focal-ctc-omr.

cjt222 avatar cjt222 commented on September 24, 2024

Now, I try to train only with ctc loss unitl converage and fintinue with focal loss, and i will update while i get result

from focal-ctc-omr.

jimitshah77 avatar jimitshah77 commented on September 24, 2024

Also keep a check on ctc_loss output range.

from focal-ctc-omr.

jimitshah77 avatar jimitshah77 commented on September 24, 2024

Final Solution:
Clip ctc_loss() instead of gradients.
I am closing this issue now!

from focal-ctc-omr.

Hubert2102 avatar Hubert2102 commented on September 24, 2024

@cjt222 hi,does FocalCtcLoss improve your CRNN accuracy?

from focal-ctc-omr.

cjt222 avatar cjt222 commented on September 24, 2024

@cjt222 hi,does FocalCtcLoss improve your CRNN accuracy?

I do not impore CRNN accuracy with FocalCtcLoss ,I do not know if I can not adjust a better alpha and gamma

from focal-ctc-omr.

Related Issues (3)

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.