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

Conv2D with Torch Creates Wrong Shape #20375

Open
i418c opened this issue Oct 18, 2024 · 2 comments
Open

Conv2D with Torch Creates Wrong Shape #20375

i418c opened this issue Oct 18, 2024 · 2 comments

Comments

@i418c
Copy link

i418c commented Oct 18, 2024

While trying to move from Keras 2 to Keras 3 with PyTorch, I ran into a problem in my model where a Conv2D layer outputs a shape wider in one dimension and shorter in another. It behaves appropriately when using the Tensorflow backend.

A reproducing gist is here.

@mehtamansi29
Copy link
Collaborator

Hi @i418c -

Thanks for reporting the issue. Here for torch backend running on keras3 for comparing output shape need to change kernel_size and stride like this conv2d = Conv2D(output_size, kernel_size=(4,4),strides=(2, 2),padding='same',activation='relu', kernel_initializer='ones',use_bias=False).
And also input_2d need to transpose to feed input to conv2d inputs_2d = inputs_2d.transpose(1,2,3,0)

Attached gist here for the reference.

Copy link

github-actions bot commented Nov 8, 2024

This issue is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you.

@github-actions github-actions bot added the stale label Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants