'LookupError: gradient registry has no entry for: SparseReduceMax in TensorFlow

I have an extremely large sparse matrix, say A, and it is stored using SparseTensor in TensorFlow to save memory usage. In my code, I have tf.sparse.reduce_max(A, axis=1). When I try to obtain the gradient of loss, I got an error: LookupError: gradient registry has no entry for: SparseReduceMax. Any idea to avoid this error?

TensorFlow version: 2.8.0



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source