You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am attempting to build a U-Net with the Keras api. For the expansive part of the network I am using Conv2DTranspose() to deconvolve/upscale. When the model is built with a fixed input size like Shape(256, 256, 3) it builds and compiles without issue. When I try to make the U-Net work for arbitrary input shapes (for difference sized/shaped images) I use an input shape of (None, None, 3) which is (-1, -1, 3) in C#. When the model builds, the output shapes of the deconvolution layers appear to be calculated incorrectly.
In the debugger I see each deconvolution layer with output shapes of: (None, -2, -2, 256), (None, -4, -4, 64), (None, -8, -8, 32), and finally (None, None6, None6, 16).
As you can see in the last shape, there is an obvious bug where there is a string concatenation of "None" + "6" = "None6". Maybe it should be an integer addition instead?
From making the same model in Python, I think all of these negative numbers should actually be "None". I had a look in the source code and found that -2 is used to represent "Unkown" dimension, so I think that might be where the -2 in the first shape comes from, and then it gets doubled in subsequent deconvolution layers.
I finally get an exception at the output layer: Tensorflow.InvalidArgumentError: 'Negative dimension size caused by subtracting 1 from -16 for '{{node conv2d_18/Conv2D}} = Conv2D[T=DT_FLOAT, data_format="NHWC", dilations=[1, 1, 1, 1], explicit_paddings=[], padding="VALID", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true](conv2d_17/Relu, conv2d_18/ReadVariableOp)' with input shapes: [?,-16,-16,16], [1,1,16,1].'
Description
I am attempting to build a U-Net with the Keras api. For the expansive part of the network I am using Conv2DTranspose() to deconvolve/upscale. When the model is built with a fixed input size like Shape(256, 256, 3) it builds and compiles without issue. When I try to make the U-Net work for arbitrary input shapes (for difference sized/shaped images) I use an input shape of (None, None, 3) which is (-1, -1, 3) in C#. When the model builds, the output shapes of the deconvolution layers appear to be calculated incorrectly.
In the debugger I see each deconvolution layer with output shapes of: (None, -2, -2, 256), (None, -4, -4, 64), (None, -8, -8, 32), and finally (None, None6, None6, 16).
As you can see in the last shape, there is an obvious bug where there is a string concatenation of "None" + "6" = "None6". Maybe it should be an integer addition instead?
From making the same model in Python, I think all of these negative numbers should actually be "None". I had a look in the source code and found that -2 is used to represent "Unkown" dimension, so I think that might be where the -2 in the first shape comes from, and then it gets doubled in subsequent deconvolution layers.
I finally get an exception at the output layer:
Tensorflow.InvalidArgumentError: 'Negative dimension size caused by subtracting 1 from -16 for '{{node conv2d_18/Conv2D}} = Conv2D[T=DT_FLOAT, data_format="NHWC", dilations=[1, 1, 1, 1], explicit_paddings=[], padding="VALID", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true](conv2d_17/Relu, conv2d_18/ReadVariableOp)' with input shapes: [?,-16,-16,16], [1,1,16,1].'
Reproduction Steps
The network building function:
When I call this function with args
GetModel(256, 256, 3, 0.001f)
it builds, prints the summary to console and compiles without error.When I call this function with
GetModel(-1, -1, 3, 0.001f)
the output shapes after calling .Apply() after .Conv2DTranspose():And the exception
The tensor passed into this method has the "None6" dimensions:
Known Workarounds
No response
Configuration and Other Information
OS: Windows 11
.Net: 6.0
Using latest nuget packages
SciSharp.TensorFlow.Redist 2.16.0
TensorFlow.Keras 0.15.0
TensorFlow.Net 0.150.0
The text was updated successfully, but these errors were encountered: