-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add argmin
and min
method in AST
#3961
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3961 +/- ##
==========================================
+ Coverage 94.85% 94.87% +0.01%
==========================================
Files 202 202
Lines 20735 20801 +66
==========================================
+ Hits 19669 19734 +65
- Misses 1066 1067 +1
|
keepdim: keep the dimension of the tensor when dim is not None | ||
algorithm: method to compute the minimum | ||
Returns: | ||
the max of the tensor self |
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.
Here is the minimum, right?
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.
Oh, it's my mistake. Thank You
|
||
t = torch.tensor([3, 1.0, 2]) | ||
x = t.fix_prec().share(*args, **kwargs) | ||
print(x.argmin) |
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.
Remove this print
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.
complete!
t = torch.tensor([[1, 2.0, 4], [3, 1.0, 2.0]]) | ||
x = t.fix_prec().share(*args, **kwargs) | ||
ids = x.argmin(dim=1).get().float_prec() | ||
assert (ids.long() == torch.argmin(t, dim=1)).all() |
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.
Q: Could you also add a test with one hot and keepdim?
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.
sure!
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 added it 😄
LGTM! |
Thank you for your review! 😄 |
Description
I add
min
andargmin
.Affected Dependencies
List any dependencies that are required for this change.
How has this been tested?
Checklist