keras
keras copied to clipboard
Reduce_sum and reduce_mean layers for Keras 3
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?
There are equivalents in Numpy. See here.
@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
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.
This issue was closed because it has been inactive for 28 days. Please reopen if you'd like to work on this further.