So I am fairly new to PyTorch and have only experience with training simple neural network architectures so far. Currently I have been thinking if it’s possible to implement affine image transformations (rotation/scaling/translations etc.) and use the MSE for image registration (ultimately calculating the transformation matrix via gradient descent). So there are 2 parts to this that I am not sure how to proceed.

The transformation matrix is a pixel-wise operation. Is there a good way to express it as a matrix multiplication for an entire image?
Once part 1 is taken care of, the next step is probably interpolation. I see pytorch has some features such as interpolate (https://pytorch.org/docs/master/nn.html#torch.nn.functional.interpolate 6) and grid_sample (https://pytorch.org/docs/0.3.0/nn.html#torch.nn.functional.grid_sample 3). I am not sure if either these fit the use case I have described above. Am I looking at the right things?