【Error】AttributeError: module ‘scipy.misc‘ has no attribute ‘logsumexp‘ 的解決辦法

Loewi大溼發表於2020-09-26
$ python -V
Python 3.7.6

需要用到scipy.misc.logsumexp(),但總是報錯

>>> x
array([[ 1., 10.],
       [ 2., 20.],
       [ 3., 30.]])
>>> scipy.misc.logsumexp(x)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'scipy.misc' has no attribute 'logsumexp'

解決辦法:將scipy.misc換成scipy.special,就可以了

>>> import scipy.special
>>> scipy.special.logsumexp(x)
30.000045400963103

相關文章