keras icon indicating copy to clipboard operation
keras copied to clipboard

Reduce_sum and reduce_mean layers for Keras 3

Open fburgaud opened this issue 1 year ago • 2 comments
trafficstars

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?

fburgaud avatar Aug 02 '24 14:08 fburgaud

There are equivalents in Numpy. See here.

newresu avatar Aug 04 '24 17:08 newresu

@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

sachinprasadhs avatar Aug 14 '24 05:08 sachinprasadhs

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] avatar Aug 29 '24 01:08 github-actions[bot]

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

github-actions[bot] avatar Sep 12 '24 01:09 github-actions[bot]

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

google-ml-butler[bot] avatar Sep 12 '24 01:09 google-ml-butler[bot]