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

来源:互联网 发布:甲骨文数据库培训 编辑:程序博客网 时间:2024/06/05 08:26

当我在运行阿里云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]))]))

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

链接 :https://yq.aliyun.com/articles/72841?spm=5176.100239.0.0.aLlJGY


参考文献

[1].

How 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
阅读全文
0 0
原创粉丝点击