1

How can you take the log base 10 of every element in a sparse matrix (COO)?

>>print type(X)
<class 'scipy.sparse.coo.coo_matrix'>

I've tried this but it doesn't work:

import math
X.data = math.log(X.data,10)
4

1 回答 1

4

使用np.log10而不是math.log10

import numpy as np
X.data = np.log10(X.data)
于 2012-09-02T22:33:20.080 回答