fix(model): correct default-metric check in HIST and IGMTF#2239
Open
genisis0x wants to merge 1 commit into
Open
fix(model): correct default-metric check in HIST and IGMTF#2239genisis0x wants to merge 1 commit into
genisis0x wants to merge 1 commit into
Conversation
metric_fn in pytorch_hist.py and pytorch_igmtf.py compared self.metric
(a string, default "") against the tuple ("", "loss") with ==, which is
never true, so the default/"loss" metric fell through to
raise ValueError("unknown metric"). Every other torch model
(pytorch_lstm, pytorch_alstm, pytorch_gru, ...) uses
`if self.metric in ("", "loss")`. Align HIST and IGMTF to the same
membership test so the default metric returns the negative loss as
intended. Closes microsoft#2163.
Author
|
@SunsetWolf when you have a moment, would appreciate a review here. Small one-line-per-file fix: HIST and IGMTF used |
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.
Description
Closes #2163.
metric_fninqlib/contrib/model/pytorch_hist.pyandqlib/contrib/model/pytorch_igmtf.pycomparesself.metricagainst a tuple with==:self.metricis a string (default""), soself.metric == ("", "loss")is never true. The default /"loss"metric therefore falls through toraise ValueError("unknown metric"), breaking validation/early-stopping for these two models with the default config.Every other torch model uses a membership test — e.g.
pytorch_lstm.py:147,pytorch_alstm.py:151,pytorch_gru.py:151:Change
Change
==toinin bothmetric_fnmethods so the default metric returns the negative loss, matching the rest of the model zoo.Testing
With
metric=""(default) or"loss",metric_fnnow returns-loss_fn(...)instead of raising.metric="ic"and unknown metrics are unaffected.