python index out of bounds_python 提示IndexError: index 10 is out of bounds for axis 0 with size 10...

展开全部

y = np.array([0,0,0])啊,也就是说len(y) = 3,所以说后面train这个函数里面for k in range(4)明显出界32313133353236313431303231363533e59b9ee7ad9431333433616261,所以会在k=3的时候报错,因为y根本没有y[3],最大就是y[2],改成for k in range(3)就好。

You try to index outside the range:

for s in range(0, M+1):

t[s] = t_min + k*s

Change to:

for s in range(M):

t[s] = t_min + k*s

And it works。

You create t with length of M:

t = np.linspace(t_min, t_max, M)

So you can only access M elements in t。

Python always starts indexing with zero. Therefore:

for s in range(M):

will do M loops, while:

for s in range(0, M+1):

will do M+1 loops。

resize,m_lfit,w_600,h_800,limit_1

扩展资料:

根据PEP的规定,必须使用4个空格来表示每级缩进(不清楚4个空格的规定如何,在实际编写中可以自定义空格数,但是要满足每级缩进间空格数相等)。

使用Tab字符和其它数目的空格虽然都可以编译通过,但不符合编码规范。支持Tab字符和其它数目的空格仅仅是为兼容很旧的的Python程序和某些有问题的编辑程序。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值