keras-team / keras

Deep Learning for humans
http://keras.io/
Apache License 2.0
61.26k stars 19.37k forks source link

Conv3D generates output on Tensorflow backend while crashes on pytorch backend #19753

Open AGFACBNNR opened 1 month ago

AGFACBNNR commented 1 month ago

As shown in this colab, I created a Conv3D layer which can generate an output tensor as following: 1716529507288 After switching the backend to Pytorch, with the same parameters and inputs, I met a crash: 1716529613721

fchollet commented 1 month ago

This is technically an invalid case (your output with TF has a size zero dimension, so it's an empty tensor). Weird that TF allows it -- but it's invalid nonetheless.

mehtamansi29 commented 1 month ago

Hi @AGFACBNNR -

I am not able to reproduce the issue in tensorflow and pytorch backend with latest versions. Attached gist for the reference with additional examples with tensorflow and pytorch backend.

AGFACBNNR commented 3 weeks ago

@mehtamansi29 Unfortunately, your code can not correctly reflect this issue. To switch the backend from tensorflow to pytorch, you have to restart the kernel (to clear the import cache). In fact your 'pytorch' result is still the tensorflow result, because TensorShape does not exist in pytorch.

@fchollet As a front end framework supporting different DL libraries, I believe Keras should generate the same results given the same inputs. Maybe adding a checker for this kind of problem?

nkovela1 commented 2 weeks ago

@AGFACBNNR Would you be open to contributing a PR to add this check to the TF backend? Thanks!