nice! I try your first suggestion and change my code as “output_2[:,:,2i:2i+2,:] = F.grid_sample(x[:,:,2i:2i+2,:], F.affine_grid(beta[i,:,:].unsqueeze(0), [1, 1, 2, 28]))”, which avoids in-place operation here, and now I can continue my working. Thanks a lot!