Thanks for the clarification. The input shape above was arbitrary, but padding will still be useful for my actual images. My question was a bit more basic, relating to the use of the trained model on images for segmentation. If I’m starting with an image, unfolding it, getting model predictions, and then piecing the original shape back together, what is the best way to keep track of each patch, if we assume they’re not overlapping (for now)?
My original code started with an empty numpy array with the shape of the original image and filled it with the patches, but it seems like this isn’t the most efficient way to process the images. I ultimately want to use the  torch.utils.data.DataLoader  1to feed all of the patches into the model, but I can’t quite understand how to keep track of their location in the original image.
My old code for getting patches:
if image.shape == (1460, 1936): #actual image shape
        x_points = np.uint16(np.linspace(80, 1460-80, 10)) #split x into 10 slices
        y_points = np.uint16(np.linspace(80, 1936-80, 12)) #split y into 12 slices
        output_mask = np.zeros([1460, 1936]) #create placeholder
        for x_coords in tqdm(x_points): #loop over x and y coordinates and fill in the placeholder
            for y_coords in y_points:
                tmp_data = image[x_coords-80:x_coords+80,y_coords-80:y_coords+80]
                tmp_data = (tmp_data-np.min(tmp_data))/np.max(tmp_data)
                X = torch.from_numpy(tmp_data)
                X = X.view(1,1,160,160).to(device, dtype = torch.float)
                prediction = model(X)
                tmp_out = prediction.cpu().detach()[0][1]>threshold
                output_mask[x_coords-80:x_coords+80,y_coords-80:y_coords+80] = tmp_out

Does it make sense to convert from a tensor back to a numpy array for each patch?
The code below gives me a padded tensor of size (108, 1, 160, 160)
x = torch.randn(1, 1460, 1936)  # batch, h, w
k = 160 # kernel size
d = 160# stride
x = F.pad(x,(x.size(2)%k // 2,x.size(2)%k // 2,
             x.size(1)%k // 2,x.size(1)%k // 2))
patches = x.unfold(1, k, d).unfold(2, k, d) 
unfold_shape = patches.size()
patches = patches.contiguous().view(-1, 1,k, k) #(108, 1, 160, 160)

Since I can’t run all patches through at once, I need to batch, collect predictions, and then unfold. That’s what I don’t understand conceptually how to do with Pytorch. Thanks again for your help.