[BUGFIX] inference feature extraction same as at the training time #397
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.
This PR fixes discrepancy in feature extraction logic at training and inference time.
I observed that extracted embedding have different numeric values, when extracted following training and inference pipelines, cosine similarity between extracted embeddings was at the level of 0.9, when it should be close to 1.0 .
With suggested fix, extracted embeddings have numerically close values, respective cosine similarities are 1.0. Though vector numerical values are still non-exact, and I didn't find yet, why is it so.
I took
compute_fbank
logic from processors that are used at training time, and made sure that the same hyperparameters for filter banks computation are used at the inference.This code snippet validates correctness of extracted embeddings.
This issue emerged with fine-tuned
ReDimNet
model, that also required to pass correct number of Mel features, which is 72 forReDimNet
. Thereafter, I suggest storing dataset params as part of class attributes.Sample output: