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
Support clamp()
with tensor min and max
#2793
Comments
Hey @zuoxingdong, how to approach this. |
I think it would ideed be a good thing. I did not find a better way than: |
any update on this ? in the meantime I guess that this is a possible alternative...
|
@yaceben thanks for the one-liner |
One could also use |
Any progress here? |
I can take up this issue if anyone hasn't. |
I've updated the labels on this function. We would still accept a PR implementing this behavior. Note that this functionality is consistent with NumPy, where np.clip can accept array-likes. |
Updating to high priority based on user activity. |
This feature will be very useful for clipping multi-channel images with different ranges for each channel. |
Summary: Fixes pytorchgh-2793 Pull Request resolved: pytorch#52695 Reviewed By: mruberry Differential Revision: D27395977 Pulled By: ezyang fbshipit-source-id: f86aa240feb034d42e4c45447e72218f6a773c24
It might be useful to extend the current
clamp()
function, where the min and max can be tensor.e.g. To clip the value for a [5, 3]-tensor, we could define min and max for each element, or each row/column.
Finally, it might be good to rename it to clip to be consistent with
numpy.clip
cc @ezyang @gchanan @zou3519 @bdhirsh @jbschlosser @mruberry @rgommers @heitorschueroff
The text was updated successfully, but these errors were encountered: