gpt4 book ai didi

python - Neurolab 的 newff 示例中出现错误

转载 作者:行者123 更新时间:2023-11-30 09:21:18 25 4
gpt4 key购买 nike

我刚刚安装了 Neurolab,并尝试了提供的示例(前馈多层感知器(newff)):

import neurolab as nl
import numpy as np

# Create train samples
x = np.linspace(-7, 7, 20)
y = np.sin(x) * 0.5

size = len(x)

inp = x.reshape(size,1)
tar = y.reshape(size,1)

# Create network with 2 layers and random initialized
net = nl.net.newff([[-7, 7]],[5, 1])

# Train network
error = net.train(inp, tar, epochs=500, show=100, goal=0.02)

# Simulate network
out = net.sim(inp)

但是我遇到了这个错误。

Traceback (most recent call last):
File "C:/Python27/newff.py", line 17, in <module>
error = net.train(inp, tar, epochs=500, show=100, goal=0.02)
File "build\bdist.win32\egg\neurolab\core.py", line 165, in train
return self.trainf(self, *args, **kwargs)
File "build\bdist.win32\egg\neurolab\core.py", line 349, in __call__
train(net, *args)
File "build\bdist.win32\egg\neurolab\train\spo.py", line 73, in __call__
from scipy.optimize import fmin_bfgs
ImportError: No module named scipy.optimize

最佳答案

您删除了训练例程调用,这可能是在网络对象中设置 .ci 属性。因此错误不在示例中,而在您的修改中。

更新(OP更改了问题)

现在问题非常简单 - 您没有安装 scipy

关于python - Neurolab 的 newff 示例中出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37088937/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com