Hi,
I am working on finding gradients of an image using the sobel operator and convolutional filters. Right now, my approach is
kernel_x = [[1., 0., -1.], [2., 0., -2.], [1., 0., -1.]]
kernel_x = torch.FloatTensor(kernel_x)
kernel_y = [[1., 2., 1.] ,[0. ,0., 0.], [-1., -2., -1.]]
kernel_y = torch.FloatTensor(kernel_y)
kernel_x = kernel_x.unsqueeze(0).unsqueeze(0)
kernel_y = kernel_y.unsqueeze(0).unsqueeze(0)
self.weight_x = nn.Parameter(data=kernel_x, requires_grad=False)
self.weight_y = nn.Parameter(data=kernel_y, requires_grad=False)
grad_x = F.conv2d(x, self.weight_x)
grad_y = F.conv2d(x, self.weight_y)

The main reason i am confused is that the weights are transposed during convolutions–and i want to calculate the x and y gradients specifically. Is this approach right?–like would grad_x calculate the x-directional gradients and grad_y the y-directional?
Input Format : [1,1,64,64]