【问题标题】:Running neural network pybrain运行神经网络 pybrain
【发布时间】:2018-03-26 10:15:43
【问题描述】:

我想创建神经网络并为其安装 scipy 和 PyBrain。 在我写的文件上:

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

当我运行该文件时,发生了错误

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

你能给点建议吗?

【问题讨论】:

  • 可能是一个过时的 scipy 版本?
  • @FerdinandBeyer scipy 的版本是 1.0.0rc1
  • 看起来 expm2 自 scipy 0.13 以来已被弃用。我没有很快找到任何证据,但它可以在您使用的版本中删除。所以你的 scipy 版本对于你的 pybrain 版本来说可能太新了。 :) docs.scipy.org/doc/scipy-0.14.0/reference/…

标签: python scipy neural-network pybrain


【解决方案1】:

这个错误信息基本上是在说:

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

尝试重新安装scipy,应该可以。

【讨论】:

  • 没有帮助
【解决方案2】:

PyBrain 使用的函数 scipy.linalg.expm2 自 v.0.13 以来已被弃用,has been removed 在 v.1.0.0 中(尚未发布):

已弃用的函数 expm2expm3 已从 scipy.linalg.

(在“向后不兼容的更改”部分)

由于 PyBrain 似乎还没有更新,您需要回退到仍然包含此功能的 Scipy 版本,例如最后一个版本 v.0.19.1。

【讨论】:

    【解决方案3】:

    我有同样的错误。我不知道它是否仍然相关,但对我来说,当我将 expm2 更改为 expm 时,错误消失了。

    【讨论】:

      【解决方案4】:

      Scipy 最新版本不包含scipy.linalg.expm2。相反,它有scipy.linalg._expm_frechet。因此,在 Pybrain (pybrain.tools.functions) 中打开该 .py 文件并将 from scipy.linalg import inv, det, svd, logm, expm2 行替换为 from scipy.linalg import inv, det, svd, logm, _expm_frechet ,它应该可以解决您的问题。

      【讨论】:

      • 截至 2019-01-26 仍然有效,即使直接安装 0.3.3 版也需要
      【解决方案5】:

      只是为了让尝试此解决方案的每个人都更轻松:

      1. 安装完pybrain库后,在python控制台输入pybrain.tools.functions,如图所示

      2. 在简单引号之间的单词“from”之后是您使用的 .py 函数文件的文件路径,如图所示 File path shown on the python console

      1. 打开它并按 CTRL + F 在文件的第一行代码中搜索 import 语句中的 expm2 引用

      2. 在import语句for expm2上,将expm2替换为_expm_frechet如图 Replacement of expm2 for _exp_frechet

      1. 现在,再次尝试运行您的代码,jupyter lab 应该可以使用 pybrain 库了

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-05-28
        • 2016-10-19
        • 2016-01-19
        • 1970-01-01
        • 2012-09-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多