Skip to content
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

Fix a bug in mean calculation of 'ys_probs' #748

Merged
merged 1 commit into from
Apr 11, 2024
Merged

Conversation

aask1357
Copy link
Contributor

A vector variable best_hyp.ys_probs contains the probabilities of each token in a matched keyword whose length is level.
The code checks if the mean of best_hyp.ys_probs is greater than or equal to a threshold.

Problem

Currently, when calculating the mean, the index ranges from 1 to level.
This excludes the first token (at index 0) and includes an undefined value at the end.
In most cases, this undefined value is zero so the code seems to work fine.

Solution

Change the index to range from 0 to level-1.

@csukuangfj
Copy link
Collaborator

@pkufool Could you have a look?

@pkufool
Copy link
Contributor

pkufool commented Apr 11, 2024

@aask1357 Though I can't recall why I wrote down this code before,after reviewing the current code carefully, I think you are right, Thanks!

@pkufool pkufool merged commit 904a3cc into k2-fsa:master Apr 11, 2024
207 of 223 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants