keras-team / keras

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

Resizing layer meets division by zero crash with jax backend #19725

Open AGFACBNNR opened 2 weeks ago

AGFACBNNR commented 2 weeks ago

As shown in this colab, Resizing meets a 'division by zero' crash with jax backend. This is triggered when 'height' is large and crop_to_aspect_ratio=True. According to the error message, it seems that after the preprocessing in Keras, jax receives an image whose dimension list contains a zero, which is directly used as a divisor in jax. Currently the output is: 1715930082639 where we can observe that the API can execute successfully when crop_to_aspect_ratio=False or 'height' is small, while meets a crash in the third time.

AGFACBNNR commented 2 weeks ago

The symptom looks similar to issue #19723, but I'm not sure whether the reasons behind are same too. Besides, I also found this problem in RandomCrop layer. Please let me know if you need a code snippet to reproduce the crash in RandomCrop.

mehtamansi29 commented 1 week ago

Hi @AGFACBNNR

Thanks for reporting the issue. I have tested the code snippet and reproduces the reported behaviour. Attached gist file for reference.

We will look into the issue and update you the same.