Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A checker is needed for inputs of Conv layers. #65214

Open
Shuo-Sun20 opened this issue Apr 8, 2024 · 1 comment
Open

A checker is needed for inputs of Conv layers. #65214

Shuo-Sun20 opened this issue Apr 8, 2024 · 1 comment
Assignees
Labels
subtype:windows Windows Build/Installation Issues TF 2.16 type:bug Bug

Comments

@Shuo-Sun20
Copy link

Issue type

Bug

Have you reproduced the bug with TensorFlow Nightly?

Yes

Source

source

TensorFlow version

tf 2.16

Custom code

Yes

OS platform and distribution

WIndows10 & Linux

Mobile device

No response

Python version

No response

Bazel version

No response

GCC/compiler version

No response

CUDA/cuDNN version

No response

GPU model and memory

No response

Current behavior?

As disscussed in #64396, it should be considered as an abnormal input when kernel_size > input_size, while currently the Conv layers will silently generate an unexpected output, therefore maybe a checker is needed here.

The code to reproduce this issue:

from keras.layers import Conv2D
import numpy as np

x=np.random.rand(1,2,2,1)
l=Conv2D(1,3,(1,1),'valid','channels_last', [1,1],1, 'linear', True)
print(l(x).shape)
print(l.compute_output_shape(x.shape))

In my opinion, this code should not generate an output, a warning or error is expected since the kernel(3x3) is larger than input (2x2).

Standalone code to reproduce the issue

from keras.layers import Conv2D
import numpy as np

x=np.random.rand(1,2,2,1)
l=Conv2D(1,3,(1,1),'valid','channels_last', [1,1],1, 'linear', True)
print(l(x).shape)
print(l.compute_output_shape(x.shape))

Relevant log output

Currently in windows, the output is
(1, 2, 2, 1)
(1, 0, 0, 1)
And in Linux the output is
(1, 0, 0, 1)
(1, 0, 0, 1)

The inconsistant is discussed in tensorflow/tensorflow#64396. This issue is to report the need of checker for abnormal inputs of Conv layers.
@Venkat6871
Copy link

Hi @Shuo-Sun20 ,

I tried to run your code on colab using TF-nightly and faced the same issue. Please find the gist here for reference.

Thank you!

@Venkat6871 Venkat6871 added the subtype:windows Windows Build/Installation Issues label Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
subtype:windows Windows Build/Installation Issues TF 2.16 type:bug Bug
Projects
None yet
Development

No branches or pull requests

2 participants