0
点赞
收藏
分享

微信扫一扫

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]))]))


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

链接 :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 条评论