首页 > 解决方案 > 在 Python 中使用 Autograd 包进行渐变

问题描述

我正在尝试使用package.json 复制这个标准示例Autograd

虽然我能够从这个存储库复制其他示例,但这个特定示例会引发如下错误:

    /home/avuis/anaconda/lib/python3.6/sitepackages/autograd/numpy/numpy_vjps.py:444: FutureWarning: 
Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. 
In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different result.
      return lambda g: g[idxs]

这个相关版本不兼容吗?如果是这样,有什么快速的方法来解决这个问题?

提前致谢,

标签: pythonautograd

解决方案


尝试将您的scipy软件包更新到较新的版本。我使用的版本是 1.0.0 并且示例有效。

但是,即使进行了更改,此示例也不起作用。它运行没有错误,但不会产生任何结果。我的猜测是 Hessian 和 Jacobian 近似是错误的,并且最小化算法不会收敛。如果尝试使用另一种最小化算法,它确实会收敛(缓慢但稳定)。存储库中应该代表输出的当前图像已经过时,因为在最新版本的代码中,风车中的类数是 3 而不是 5。


推荐阅读