fix: softmax in predict() method only on the scores of the selected labels#1
Open
jradola wants to merge 1 commit intocisnlp:mainfrom
Open
fix: softmax in predict() method only on the scores of the selected labels#1jradola wants to merge 1 commit intocisnlp:mainfrom
jradola wants to merge 1 commit intocisnlp:mainfrom
Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Replace
softmax_result = self._softmax(result_vector)[self.language_indices]with
softmax_result = self._softmax(result_vector[self.language_indices]).This way we make sure that after restricting the set of labels the assigned probabilities sum up to 1, instead of taking the results at given language indices after softmaxing over all languages.
Example:
Output before:
(('__label__pol_Latn', '__label__eng_Latn'), array([4.6378150e-06, 2.2964262e-15], dtype=float32))Output after:
(('__label__pol_Latn', '__label__eng_Latn'), array([1.000000e+00, 4.951526e-10], dtype=float32))