出现错误IndexError: index 1 is out of bounds for axis 0 with size 1
import numpy as npimport random
i = 0
s = random.uniform(-1.5, 1.5)
X = np.random.randint(-1000, 1000, (1 , 1000))
Y = np.ones(, dtype=float)
def fun(x):
return 8.0*x + 9.0 + s
while i < 1002:
Y = fun(X)
print(Y)
print(X)
i += 1 错误代码意思是索引下标 1 越界了。
是不是np.ones的参数写错了?
我记得np.ones的第一个参数好像是元组吧,用来描述矩阵的形状大小,你写的是一个列表。不知道是不是这里错了。我没试过这样写。
页:
[1]