How to find norm of a sparse matrix in mxnet ? Please note that is should not be the normal norm operation in ndarray it should be for sparse matrices, is there any support as such in mxnet ?

# Norm of sparse matrix

**safrooze**#2

There is no `norm()`

operator for sparse NDArray, however you can calculate it yourself using `square()`

, `sum()`

, and `sqrt()`

. However be careful with sum because it is only implemented for CSR sparse array (for row-sparse it falls back to NDArray and has to convert the storage to a dense one). Something like the following code should do:

```
def csr_norm(csr_array):
assert isinstance(csr_array, mx.nd.sparse.CSRNDArray), "array is not CSRNDArray"
return csr_array.square().sum(0).sum().sqrt()
```

Actually there’s an implementation sitting in my fork but I don’t have the time to PR it yet.

This implements the norm operator, which can be used to inspect row sparse weight/gradient