I want to crop the image after using nn.ConvTranspose2d, but I can not find some relative function...
seems that there aren't such methods, try something like this:
w, h = variable.size
x1 = int(round((w - tw) / 2.))
y1 = int(round((h - th) / 2.))
you could also use F.pad with negative number for cropping, but you will have to figure out the amount of padding manually: http://pytorch.org/docs/nn.html#torch.nn.functional.pad