简体   繁体   English

运行神经网络 pybrain

[英]Running neural network pybrain

I want to create neural network and install scipy and PyBrain for it.我想创建神经网络并为其安装 scipy 和 PyBrain。 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?你能给点建议吗?

Scipy latest version doesn't contain scipy.linalg.expm2 . Scipy最新版本不包含scipy.linalg.expm2 Instead, it has scipy.linalg._expm_frechet . 相反,它有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. 因此在Pybrain中打开.py文件(pybrain.tools.functions)并用from scipy.linalg import inv, det, svd, logm, expm2替换from scipy.linalg import inv, det, svd, logm, _expm_frechet它应该解决你的问题。

This error message is basically saying: 此错误消息基本上是这样说:

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

Try reinstalling scipy , that should do it. 尝试重新安装scipy ,应该这样做。

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): scipy.linalg.expm2使用的函数scipy.linalg.expm2自v.0.13起已被弃用, 并已在v.1.0.0中删除 (尚未发布):

The deprecated functions expm2 and expm3 have been removed from scipy.linalg . 已弃用的函数expm2expm3已从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. 由于PyBrain似乎尚未更新,您需要回退到仍包含此功能的Scipy版本,例如上一版本v.0.19.1。

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. 我不知道它是否仍然相关,但对我来说,当我将expm2更改为expm时,错误消失了。

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安装pybrain库后,在python控制台中,输入pybrain.tools.functions ,如图所示

  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在简单引号之间的单词“from”之后是您的 .py 函数文件的文件路径,如图所示文件路径显示在 python 控制台上

  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打开它并按CTRL + F在文件的第一行代码中的 import 语句中搜索expm2引用

  2. on the import statement for expm2 , replace expm2 for _expm_frechet as shown on the figure Replacement of expm2 for _exp_frechetexpm2的 import 语句,将expm2替换为_expm_frechet ,如图所示将expm2替换为_exp_frechet

  1. now, try running your code again and jupyter lab should work with the pybrain library现在,再次尝试运行您的代码,jupyter 实验室应该可以与 pybrain 库一起使用

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"要解决这个问题,你可以这样做:在“C:\Users<user-name>\AppData\Local\Programs\Python\Python310\Lib\site-packages\pybrain\tools”中找到文件“functions.py”

Find this command "from scipy.linalg import", and then change "expm2" to "expm", do it in this function too "def sqrtm(M)":找到这个命令“from scipy.linalg import”,然后把“expm2”改成“expm”,在这个function中也做“def sqrtm(M)”:

"expm2(0.5 * logm(M)" to "expm(0.5 * logm(M)". “expm2(0.5 * logm(M)”到“expm(0.5 * logm(M)”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM