This well written blog can be util for you:
The first part is basically a from scratch numpy implementation of an affine transformation.

  
      
      Kevin Zakka’s Blog – 10 Jan 17
  
  
    

Deep Learning Paper Implementations: Spatial Transformer Networks - Part I 169

Part I covers affine image transformations and bilinear interpolation.


  
  
    
    
  
  


and the second part delves into stn:

  
      
      Kevin Zakka’s Blog – 18 Jan 17
  
  
    

Deep Learning Paper Implementations: Spatial Transformer Networks - Part II 94

In part II, we cover the Spatial Transformer module and summarize its paper in detail.


  
  
    
    
  
  


Hope this can help you.
Cheers.