coords[:,1] = coords[:,1] - (x.size(2) / 2. + 0.5)
// apply the coordinate transformation
new_coords = F.linear(coords, A, b)
if center:
// shift the coordinates back so origin is origin
new_coords[:,0] = new_coords[:,0] + (x.size(1) / 2. + 0.5)
After Change
2D Affine image transform on torch.autograd.Variable
if matrix.dim() == 2:
matrix = matrix.view(-1,2,3)
A_batch = matrix[:,:,:2]
if A_batch.size(0) != x.size(0):
A_batch = A_batch.repeat(x.size(0),1,1)
b_batch = matrix[:,:,2].unsqueeze(1)