Add output padding for ConvTranspose #2462
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR provides the ability to increase
ConvTranspose
's output shape when stride > 1, implemented in the same way as in PyTorchoutput_padding
(see ConvTranspose3d and NaiveConvolutionTranspose3d.cpp).The purpose of this is to conserve
Conv
/ConvTranspose
inversability. For stride = N, N>1, there are N possibilities per dimension that result in the sameConv
output (see what-output-padding-does-in-nn-convtranspose2d). The added argumentoutpad
controls how much the output shape is increased to match the stridedConv
counterpart. Can be provided as an integer to equally increase all dimensions, or as a tuple for individual dimensional control).outpad
is invalid if anyoutpad
.>=stride
. Currently there is no verification of this when constructingConvTranspose
, it only breaks when called and throws DimensionMismatch. A similar thing happens in PyTorch, it allows constructing ConvTransposeNd with invalidoutput_paddding
, but then throws RuntimeError before doing the deconvolution. As the verification can be done in the constructor, it makes sense to handle it there, but let me know what you think.I tried to follow the variable naming style, but it can also be changed if you see a better fitting alternative. The same applies for other things such as argument order.
PR Checklist