AttributeError: 'numpy.ndarray' object has no attribute 'index'

网友投稿 2235 2022-08-22

AttributeError: 'numpy.ndarray' object has no attribute 'index'

AttributeError: 'numpy.ndarray' object has no attribute 'index'

当我在运行阿里云PAI代码的时候,预测代码会报错,查了资料才发现numpy居然没有index,python学得还是蛮痛苦和纠结的

错误的代码:

print ("This is a %s"%(num[prediction[0].index(max(prediction[0]))]))

正确的代码为:

print ("This is a %s"%(num[prediction[0].tolist().index(max(prediction[0]))]))

【玩转数据系列十】利用阿里云机器学习在深度学习框架下实现智能图片分类,

链接 :to find the index of an array within an array​​

​​https://stackoverflow.com/questions/21488005/how-to-find-the-index-of-an-array-within-an-array​​

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:统计学习方法笔记:逻辑斯谛回归与最大熵模型(下)
下一篇:6 个可以让代码变得更整洁的 Android 库(618是什么意思)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~