for a convolution i want to apply a circular padding in one dimension and a zero padding in all other dimension. How can i do this?
For the convolution there are 28 channels and fore the the data is described in spherical bins. There are 20 bins for radius times 20 bins for polar times 20 bins for inclination. The circular padding should only be applied for the inclination.
Small Example
# Example:
x = torch.tensor([[1,2,3],
[4,5,6],
[7,8,9]])
y = sphere_pad(x, pad=(0, 1))
# y is now tensor([[3, 1, 2, 3, 1],
# [6, 4, 5, 6, 4],
# [9, 7, 8, 9, 7]])
I have tried to apply
def sphere_pad(x, pad=(1,1)):
return x.repeat(*x.shape)[
(x.shape[0]-pad[0]):(2*x.shape[0]+pad[0]),
(x.shape[1]-pad[1]):(2*x.shape[1]+pad[1])]
and then apply a convolution with a normal zero padding ( and no padding in the last dimension). This works for a small example but this method exceeds the GPU memory for the actual problem size. Are there other ways?