- 目标
Get the all index on the featuremap when the conv sliding on the featuremap
-
Get the coordinates of conv(e.g., 3x3) and featuremap(e.g., 5x5)
- c_x_y: relative coordinates(1,18) of conv
- p_x_y: coordinates(1, 18, 5, 5) of featuremap
# c_x_y: relative coordinates of conv # p_x_y: kernel_size = 3 r = kernel_size // 2 c_x, c_y = torch.meshgrid(torch.linspace(-r, r, 2*r+1) torch.linspace(-r, r, 2*r+1)) c_x_y = torch.cat((x,reshape(-1,1), y.reshape(-1,1)),dim=1) h=5 w=5 p_x, p_y = torch.meshgrid(torch.linspace(1, h, h), torch.linspace(1, w, w)) p_x = p_x.expand(1, kernel_size * kernel_size, h, w) p_y = p_y.expand(1, kernel_size * kernel_size, h, w) p_x_y = torch.cat((p_x, p_y), dim=1) -
combine conv and featuremap
- p: it's shape is same as p_x_y
p = c_x_y.reshape(1, 2*kernel_size*kernel_size, 1, 1) + p_x_y