您的位置:首页 > 移动开发 > Objective-C

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

2017-09-13 14:43 2176 查看
当我在运行阿里云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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: