// make a meshgrid of normal coordinates
//coords = th_iterproduct_like(x).float()
coords = th_iterproduct(x.size(1),x.size(2)).float()
if center:
// shift the coordinates so center is the origin
coords[:,0] = coords[:,0] - (x.size(1) / 2. + 0.5)
coords[:,1] = coords[:,1] - (x.size(2) / 2. + 0.5)
// apply the coordinate transformation
new_coords = coords.mm(A.t().contiguous()) + b.expand_as(coords)
if center:
// shift the coordinates back so origin is origin
new_coords[:,0] = new_coords[:,0] + (x.size(1) / 2. + 0.5)
new_coords[:,1] = new_coords[:,1] + (x.size(2) / 2. + 0.5)
// map new coordinates using bilinear interpolation
if mode == "nearest":
After Change
b_batch = matrix[:,:,2].unsqueeze(1)
// make a meshgrid of normal coordinates
_coords = th_iterproduct(x.size(1),x.size(2))
coords = _coords.unsqueeze(0).repeat(x.size(0),1,1).float()
if center:
// shift the coordinates so center is the origin
coords[:,:,0] = coords[:,:,0] - (x.size(1) / 2. + 0.5)
coords[:,:,1] = coords[:,:,1] - (x.size(2) / 2. + 0.5)
// apply the coordinate transformation
new_coords = coords.bmm(A_batch.transpose(1,2)) + b_batch.expand_as(coords)
if center:
// shift the coordinates back so origin is origin
new_coords[:,:,0] = new_coords[:,:,0] + (x.size(1) / 2. + 0.5)
new_coords[:,:,1] = new_coords[:,:,1] + (x.size(2) / 2. + 0.5)
// map new coordinates using bilinear interpolation
if mode == "nearest":