Repository navigation
Fix transposed convolutions with unknown batch or spatial sizes, add 3D - #41
Open
Shaisolaris wants to merge 3 commits into
Open
Shaisolaris wants to merge 3 commits into
Shaisolaris wants to merge 3 commits into
Conversation
Build the transposed convolution output shape from tf.shape(inputs) so the batch size and any spatial size that is unknown at trace time come from the runtime input. ComplexConv1D and ComplexConv2D with transposed=True now train and accept variable-size inputs, and ComplexConv3D with transposed=True is implemented with tf.nn.conv3d_transpose. Fixes JesperDramsch#39
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #39.
The transposed convolution helpers built
output_shapefrom the static input shape. Duringfitandpredictthe batch size isNone, soComplexConv1D(..., transposed=True)failed with aConcatV2type error, and any input with an unknown spatial size failed the same way in 1D and 2D.ComplexConv3Dwithtransposed=Truehad no implementation and raisedKeyError: 3.Changes:
tf.shape(inputs), using the runtime batch size and the runtime value of any spatial size that is unknown at trace time. Static sizes still go throughconv_utils.deconv_output_length.conv1d_transpose,conv2d_transposeand the newconv3d_transposeswap the kernel's input and output channel axes, then calltf.nn.conv_transpose. 3D uses the(0, 1, 2, 4, 3)permutation.ComplexConv1Dfrom the list of things that don't work.Tests: the new
TestTransposedConvTrainingclass intests/test_conv.pycompiles each model, callspredictand fits it for one epoch:validwith variable sizes 6x6 and 5x9;On
mainall 4 fail. With this change they pass, and the full suite gives 85 passed, 1 xfailed. I ran this on CPU only, with TensorFlow 2.21 and Keras 3.15, and didn't test thechannels_firstpath.