Open pimdh opened 4 years ago
Thanks for this suggestion, @pimdh. Would an implementation of a pad function like NumPy's pad also solve this issue?
I want to second @pimdh's feature request. And I think, @mruberry, that numpy's pad would solve any need like this (in my case I'd use 'edge')
'ValueError: Only "zeros" padding mode is supported for ConvTranspose2d'. Why this error still occurs in 2024? Is there no way to use circular padding mode in ConvTranspose2d?
🚀 Feature
Support the padding modes implemented in ConvNd also for ConvTransposeNd
Motivation
When using CNNs on physics models which live on periodic lattices, such as the Ising model, circular/periodic padding mode is the only sensible thing to do. When we want the CNN to output values on the lattice points (=pixels), I'd like to downsample with convolution with stride, then upsample with transposed convolution. This requires circular/periodic padding to be an option to ConvTransposeNd.
Pitch
Comparing Conv2D (https://github.com/pytorch/pytorch/blob/master/torch/nn/modules/conv.py#L381) with ConvTranspose2D (https://github.com/pytorch/pytorch/blob/master/torch/nn/modules/conv.py#L819), it looks like all that is needed is a call to F.pad. However, maybe some calculations on the padding size need to be done.