Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Element wise exp() of scipy sparse matrix

I have a very big sparse csc_matrix x. I want to do elementwise exp() on it. Basically what I want is to get the same result as I would have got with numpy.exp(x.toarray()). But I can't do that(my memory won't allow me to convert the sparse matrix into an array). Is there any way out? Thanks in advance!

like image 924
Bishwajit Purkaystha Avatar asked Sep 19 '25 17:09

Bishwajit Purkaystha


1 Answers

If you don't have the memory to hold x.toarray(), you don't have the memory to hold the output you're asking for. The output won't be sparse; in fact, unless your input has negative infinities in it, the output probably won't have a single 0.

It'd probably be better to compute exp(x)-1, which is as simple as

x.expm1()
like image 106
user2357112 supports Monica Avatar answered Sep 23 '25 12:09

user2357112 supports Monica



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!