Konstantin Penzev
Konstantin Penzev

Reputation: 67

Running neural network pybrain

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?

Upvotes: 2

Views: 5599

Answers (6)

Denzy Legacy
Denzy Legacy

Reputation: 1

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)".

Upvotes: 0

filipebcs8
filipebcs8

Reputation: 1

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

Upvotes: 0

Danish366
Danish366

Reputation: 121

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.

Upvotes: 7

Muriel
Muriel

Reputation: 11

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.

Upvotes: 0

Ferdinand Beyer
Ferdinand Beyer

Reputation: 67207

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.

Upvotes: 0

Adi219
Adi219

Reputation: 4814

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.

Upvotes: 0

Related Questions