2

I want to create neural network and install scipy and PyBrain for it. On file i write:

from pybrain.tools.shortcuts import buildNetwork
net=buildNetwork(4,2,1)

and when i run that file, an error occured

from scipy.linalq import inv,det, svd, logm, expm2
ImportError: cannot import name expm2

Can you advise something?

6 Answers6

7

Scipy latest version doesn't contain scipy.linalg.expm2. Instead, it has scipy.linalg._expm_frechet. So open up that .py file in Pybrain (pybrain.tools.functions) and replace the line from scipy.linalg import inv, det, svd, logm, expm2 with from scipy.linalg import inv, det, svd, logm, _expm_frechet and it should solve your problem.

Danish366
  • 81
  • 1
  • 9
0

This error message is basically saying:

expm2 isn't installed. i.e. Your scipy version hasn't got expm2 or something went wrong during the installation.

Try reinstalling scipy, that should do it.

Adi219
  • 4,712
  • 2
  • 20
  • 43
0

The function scipy.linalg.expm2 used by PyBrain has been deprecated since v.0.13 and has been removed in v.1.0.0 (not yet released):

The deprecated functions expm2 and expm3 have been removed from scipy.linalg.

(In section "Backwards incompatible changes")

As it seems that PyBrain has not been updated yet, you need to fall back to a Scipy version that still contains this function, such as the last release v.0.19.1.

Ferdinand Beyer
  • 64,979
  • 15
  • 154
  • 145
0

I had the same error. I don't know if it is still relevant, but for me the error dissapeared when I changed expm2 to expm.

Muriel
  • 11
0

Just to make things easier for everyone out there trying this solution:

  1. in the python console after installing the pybrain library, type pybrain.tools.functions as the attached figure is showing up

  2. after the word "from" between simple quotes is your file path for the .py functions file used as show on the figure File path shown on the python console

  1. open it up and press CTRL + F to search for the expm2 reference in the import statement amongst the first lines of code in the file

  2. on the import statement for expm2, replace expm2 for _expm_frechet as shown on the figure Replacement of expm2 for _exp_frechet

  1. now, try running your code again and jupyter lab should work with the pybrain library
0

To solve this problem u can do it: Find the file "functions.py" in "C:\Users<user-name>\AppData\Local\Programs\Python\Python310\Lib\site-packages\pybrain\tools"

Find this command "from scipy.linalg import", and then change "expm2" to "expm", do it in this function too "def sqrtm(M)":

"expm2(0.5 * logm(M)" to "expm(0.5 * logm(M)".

Dhytm
  • 1
  • 1