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

[src] Correctrly treat subsampling factor != 1 in nnet3-get-egs #4183

Merged
merged 1 commit into from
Jul 19, 2020

Conversation

kkm000
Copy link
Contributor

@kkm000 kkm000 commented Jul 19, 2020

Fixes #4167


Dan, I do not like how easy and error-prone it currently is to confuse subsampled and continuous indices. I'm thinking of a helper struct constructed like Resample resample(factor,offset) with methods int32 resample.Down(int32) and int32 resample.Up(int32). I looked at the code if it were possible to have different, non-decayable separate types for continuous and downsampled indices, so that they cannot be assigned one to another, but it's probably not possible, as at some points we just simply do not know. But this helper I think I'll implement.

I read other binaries' code to check if they have the same problem, and it's not very readable, and hard to trace. At the very least, an explicit object doing the trivial arithmetic should make the code a bit easier to grok.

@kkm000 kkm000 requested a review from danpovey July 19, 2020 04:12
Copy link
Contributor

@danpovey danpovey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
At this point I'd rather not make much code changes except for fixes. Regarding further changes to reduce the chance of these types of errors: I think the disruption from the chance of breaking stuff would outweigh the benefit.

@kkm000
Copy link
Contributor Author

kkm000 commented Jul 19, 2020

Thanks for checking! Was just going to e-mail you, but you noticed the PR.

Regarding the encapsulation of subsampling--the code should be more readable, the readability is one of our strengths. I'm mot very insistent on making these changes, but reading the code is not easy. I've gone through other binaries in nnet3bin yesterday looking for the same mistake, and, frankly, I cannot tell for sure it's not present in other files. Some spots I just could not decipher. That's not a good sign. I'm trying to think how to better explicitly mark which indices are downsampled at the least for human consumption. If I could also recruit a compiler's help by making them different, not implicitly convertible types, that would be ideal, but I already see where it's not going to work.

Breaking stuff--agree, any change to convoluted code has such risks, but balanced by decreasing chances of breaking stuff in the future.

I'll think more of this, but not rushing. Too much new stuff to do, too little time to catch up.

@kkm000 kkm000 merged commit 960454c into kaldi-asr:master Jul 19, 2020
@kkm000 kkm000 deleted the 2007-nnet-subsample branch July 19, 2020 07:15
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.

./src/nnet3bin/nnet3-get-egs.cc with frame_subsampling_factor != 1
2 participants