Hi,
Given an input tensor (1x3xNxN) representing an image which undergoes many 2d convolutions/maxpool transformations, I obtain an output tensor (1xKxMxM) with K an arbitrary number of dimension (one per filter of the last layer) and M the side of the output tensor.
What I would like to do, is given a slice Z in the output generated by one of the K final filters
Z=([x1,x2],[y1,y2]) with 0 <= x1 <= x2 <= M, 0 <= y1<= y2 <= M,
recover the original input slice  Z’=([x1’,x2’],[y1’,y2’]) with
0<= x1’ <= x2’ <= N ,0<= y1’<=y2’<=N
which was the crop of the image which allowed to generate the area in the output layer. I already have a working code for a single convolutional layer and a “single-pixel” (x1’=x2’=x) output interval:
x1’ = max(x S-P,0) x2’  = min(xS +K-P,N)
where S = stride size, P = padding, K = kernel size, N = input size
Is there a way to obtain this using pytorch code exclusively? The current approach would be far from ideal. Thank you for any help!