Skip to content

Commit

Permalink
fix(layers): Update Conv2D docstring to clarify numerical precision a…
Browse files Browse the repository at this point in the history
…cross backends (#20867)

* fix(layers): Update Conv2D docstring to clarify numerical precision across backends

Clarify that Conv2D operations may exceed the documented 1e-7 precision difference across backends

Document that large convolutions can show notable variations due to accumulated floating-point operations

* Update conv2d.py

---------

Co-authored-by: François Chollet <[email protected]>
  • Loading branch information
harshaljanjani and fchollet authored Feb 6, 2025
1 parent 43f40d8 commit 3906e32
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions keras/src/layers/convolutional/conv2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ class Conv2D(BaseConv):
and added to the outputs. Finally, if `activation` is not `None`, it is
applied to the outputs as well.
Note on numerical precision: While in general Keras operation execution
results are identical across backends up to 1e-7 precision in float32,
`Conv2D` operations may show larger variations. Due to the large
number of element-wise multiplications and additions in convolution
operations, especially with large inputs or kernel sizes, accumulated
floating-point differences can exceed this 1e-7 threshold. These variations
are particularly noticeable when using different backends (e.g., TensorFlow
vs JAX) or different hardware.
Args:
filters: int, the dimension of the output space (the number of filters
in the convolution).
Expand Down

0 comments on commit 3906e32

Please sign in to comment.