Function for "unstriding"

I need to unstride a tensor, i.e. input a tensor, insert zeros between all items and return a tensor twice as large (in the spatial dimensions). Is this possible to do?

Note I’ve found a hacky workaround by using max unpooling but it looks like a mess.

I’m working with the TensorComprehension integration and need such a function to backprop a strided convolution as this part can’t be done in TC.

Would this work?

a = torch.randn(10, 10)
b = torch.zeros(20, 20)
b[::2, ::2] = a
print(b)

@ptrblck this seems to work - marvelous! Could you explain what ‘::’ does?

EDIT: Google helped me - this is great, thanks!