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 nn.CenterCrop1d and nn.CenterCrop2d #1331
Comments
Hum, I think the type of cropping that one might want to apply might be problem-specific (not necessarily only center crop). |
What about caffe's crop layer? |
Caffe doesn't give you the ability to easily manipulate the tensors, so there is a need of such layer. The same applies for lua torch, as you need to define a module that will compute the operation that can be differentiated, but in pytorch you can just directly manipulate the tensors and the backprop will be performed. |
Even though it's easy to do it with indexing, I think it'd be better to provide some standard crops in the library. It's much more convenient than messing with indices, and can save making a few errors along the way each time you need to crop. |
+1 to this. I think standard cropping layers would be great! |
I could make a PR this week if there is consensus on API. |
I think |
Is it reasonable to include non-symmetric cropping in this API as well? |
@andrewgiessel See the current proposition at #1349. I think it would be also reasonable to specify center crop in more detail (e.g. you want to crop 10 -> 3 you have one offset 3 and one 4 but you cants specify the order at the moment). |
This can be achieved by passing a negative pad in |
Fixes #1331 Added an entry for device constant
There are some models which use "crop layers" (e.g. U-Net, ParseNet) so I think it wouldn't be bad to have a
CenterCropNd
layer.As
F.pad
supports negative padding we just need to calculate padding offsets on top.I can send a PR on interest.
The text was updated successfully, but these errors were encountered: