-
Notifications
You must be signed in to change notification settings - Fork 386
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: Support tensors and arrays for class_weight #1413
Conversation
@microsoft-github-policy-service agree company="Geomatic.AI Pty Ltd" |
Avoids ambiguous truth value ValueError when the class_weight input parameter is either a PyTorch tensor or a NumPy array. Includes new tests for SemanticSegmentationTask's class_weight parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At some point before the 0.5 release (expected in August) I'm planning on making all arguments explicit (as opposed to using **kwargs
) so we can add type hints. So remind me to make sure all sequences are permitted, not just Tensors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't yet see a simpler way to handle this other than documenting that only lists are allowed. Maybe @nsutezo can review too.
Working on type hints in #1541 and it's actually difficult to support lists, arrays, and tensors. Might just support tensors since that's what |
I think that's a good idea, as a user I'd expect tensors as first preference, and it's easy for callers to change arrays and lists into a tensor themselves. |
Avoids ambiguous truth value
ValueError
when the class_weight input parameter is either a PyTorch tensor or a NumPy array.Repro follows—also fails with
np.array
insteadtorch.tensor
, succeeds with Python sequence.Expected:
Actual: