keras-team / keras

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

Reduce_sum and reduce_mean layers for Keras 3 #20085

Closed fburgaud closed 3 days ago

fburgaud commented 1 month ago

Good morning, Tensorflow recently moved to Keras 3. Before 2.16 (I believe), it was on Keras 2, and was allowing steps like tf.reduce_sum in the composition of a model. Now, everything has to be a Layer of custom Layer. So, I do get that there are some alternatives, such as using a custom Layer or a Lambda, but reduce_sum/reduce_mean are useful functions (e.g. getting the average of a bunch of embeddings), and custom Layer or Lambda have their own limitations which make things a lot less frictionless (e.g. serializing/deserializing). Would be nice to have real layers for those?

ghsanti commented 1 month ago

There are equivalents in Numpy. See here.

sachinprasadhs commented 1 month ago

@ghsanti , Thanks for pointing it out.

@fburgaud , With the multi backend support in Keras 3, in order to follow similar naming convention and implementation among Numpy, PyTorch, Jax and TensorFlow it has been named as ops.mean and ops.sum

github-actions[bot] commented 2 weeks ago

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[bot] commented 3 days ago

This issue was closed because it has been inactive for 28 days. Please reopen if you'd like to work on this further.

google-ml-butler[bot] commented 3 days ago

Are you satisfied with the resolution of your issue? Yes No