torch.nn.functional.affine_grid
- torch.nn.functional.affine_grid(theta, size, align_corners=None)
Generate 2D or 3D flow field (sampling grid), given a batch of affine matrices
theta.
Generate 2D or 3D flow field (sampling grid), given a batch of affine matrices theta.
This function is often used in conjunction with grid_sample()
to build Spatial Transformer Networks .
theta (Tensor) – input batch of affine matrices with shape () for 2D or () for 3D
size (torch.Size) – the target output image size. ( for 2D or for 3D) Example: torch.Size((32, 3, 24, 24))
align_corners (bool, optional) – if True, consider -1 and 1
to refer to the centers of the corner pixels rather than the image corners.
Refer to grid_sample() for a more complete description.
A grid generated by affine_grid() should be passed to grid_sample()
with the same setting for this option.
Default:
output Tensor of size ()
output (Tensor)