What is the equivalent of Theano's images2neibs


(Adriano Pinto) #1

In order to partition an image into smaller patches, during training, in Theano we can take advantage of theano.tensor.nnet.neighbours package that contains images2neibs, neibs2images. How can it be performed in PyTorch?

Cheers :slight_smile:


(Adam Paszke) #2

No, I’m afraid we don’t have any operation like that. You can open a feature request in the main repository if you want.


#3

You can hack up a conv operation to do this.

If you want a patch of say 8x8 just do a 8x8x64 convolution with zero padding and let the kernel be 1’s in different positions with all zeros. After you do this your 1x1x64 will be your 8x8 patches.

This will probably be very inefficient with maximally sparse convolutions, but unless you intend to do this in an iterative manner it shouldn’t be noticeable. And should be faster than any loop you can cook up probably. With some extra effort you can make a better array programming solution, something involving reshapes and permutes probably.


(Francisco Massa) #4

This is actually equivalent to im2col and col2im in the main repo. Just need to wrap it in python with a nice interface.


(Skand Vishwanath Peri) #5

@apaszke Is the function added as of now? (Since the last update on this thread was in March!)