-
Notifications
You must be signed in to change notification settings - Fork 458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement ctc loss function #1049
Closed
Closed
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
3365b50
implement ctc loss function
wcshds f92b945
remove vec! macro
wcshds 4ddfbb3
fix wrong indice when assign initial val to alpha
wcshds 92d694d
update test case
wcshds 71fc4df
remove batch loop
wcshds 0813605
cache current_target_primes
wcshds dd9cf8b
make sure tensors are on the same device
wcshds 94d52d2
use clamp_min instead of mask_where
wcshds 7121852
remove squence loop
wcshds eb5357f
use into_scalar in assertions
wcshds 5c57283
reduce the size of log alphas
wcshds 7d047cd
wordaround for slice bug on libtorch backend #1055
wcshds 9599f32
reduce the size of one_hot
wcshds 25972ce
make sure tensors are on the same device
wcshds 08f837f
Merge branch 'tracel-ai:main' into ctc-loss
wcshds 2758b1b
adapt to burn's new device api
wcshds 9315d98
make sure the argument of the logarithm greater than 0
wcshds 08dd4eb
refactor the small value used to prevent log(0) into a constant
wcshds 4f009fc
fix typo
wcshds 0b99922
remove unnecessary code
wcshds File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean to have this number as negative? The literal number you has is positive. In an unlikely event,
(l1 - m.clone()).exp() + (l2 - m.clone()).exp()
expression could be equal toabs(DELTA)
which would still lead to log(0) situation.Additionally, I suggest we use [https://doc.rust-lang.org/std/primitive.f32.html#associatedconstant.EPSILON](f32's EPSILON) or [f16's EPSILON]https://docs.rs/tract-core/latest/tract_core/prelude/struct.f16.html#associatedconstant.EPSILON constants depending what on Backend's precision settings. @nathanielsimard or @louisfd can suggest on how we can extract this.
-1e-5
seems a rather big number for f16 or f32. (probably it may not work for f16 because its epsilon is4.88e-04
. we need to double check it)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry, it's a typo.
DELTA
should be positive.1e-5
can ensure that the results of the loss are accurate to three decimal places, but4.88e-4
is a bit large. Perhaps CTC Loss is indeed not suitable for the use of half-precision training.