I noticed that we only support kernel (1,1) for TF conv2d_transpose
with SAME padding.
test_forward.py L381
I think we can support conv2d_transpose
with SAME padding for any kernels.
We just need to run conv2d_transpose
with VALID padding (0, 0) and then de-pad the output.
I prepared SAME
and VALID
outputs for kernel (3,3) below. As you can see the middle part of VALID
output is the same as SAME output.
Looks like in order to support SAME padding with non-(1,1) kernel we just need to de-pad (slice) VALID conv2d_transpose
output.
conv2d_transpose SAME output (1,3,3,2)
[[[[1.2143719 1.3307922]
[2.3303804 2.4103665]
[2.0152621 1.9104322]]
[[2.0949996 2.192451 ]
[3.8877935 3.8518226]
[3.222784 2.938037 ]]
[[1.5925353 1.5517256]
[2.834947 2.6255574]
[2.238522 1.9052962]]]]
conv2d_transpose VALID output (1,5,5,2)
[[[[0.17881976 0.22647332]
[0.5173658 0.60219085]
[1.036694 1.134966 ]
[0.9461776 0.9461233 ]
[0.60248697 0.5678561 ]]
[[0.44633663 0.52967083]
[1.2143719 1.3307922 ]
[2.3303804 2.4103665 ]
[2.0152621 1.9104322 ]
[1.2389357 1.1096866 ]]
[[0.8069978 0.9107976 ]
[2.0949996 2.192451 ]
[3.8877935 3.8518226 ]
[3.222784 2.938037 ]
[1.9267566 1.6641226 ]]
[[0.65010977 0.67964244]
[1.5925353 1.5517256 ]
[2.834947 2.6255574 ]
[2.238522 1.9052962 ]
[1.2932158 1.0435019 ]]
[[0.38155985 0.3777752 ]
[0.8960915 0.830614 ]
[1.54699 1.3679438 ]
[1.1761999 0.9574436 ]
[0.66193414 0.51196814]]]]