keras
keras copied to clipboard
Conv2D with Torch Creates Wrong Shape
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.
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.
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.
This issue was closed because it has been inactive for 28 days. Please reopen if you'd like to work on this further.