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]))]))正确的代码为:
【玩转数据系列十】利用阿里云机器学习在深度学习框架下实现智能图片分类,
链接 :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
错误的代码:
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
相关文章推荐
- 关于AttributeError:'numpy.ndarray' object has no attribute 'index'
- AttributeError: 'numpy.ndarray' object has no attribute 'value_counts'
- 'numpy.ndarray' object has no attribute 'values'
- Python 保存数组至.mat文件,报错:AttributeError: 'numpy.ndarray' object has no attribute 'items'
- AttributeError: 'module' object has no attribute 'text_format'
- AttributeError: 'NoneType' object has no attribute 'sc' 解决方法(二)
- AttributeError: 'tuple' object has no attribute 'Multi'
- AttributeError: 'module' object has no attribute 'reader'
- AttributeError: 'Tensor' object has no attribute '_keras_history'
- AttributeError: 'module' object has no attribute 'text_format'
- 执行《机器学习实战》15章代码15-3出现AttributeError: 'MRmean' object has no attribute 'mr'
- pylons 1.0 AttributeError: 'ContextObj' object has no attribute "xxx"
- AttributeError: type object 'IOLoop' has no attribute 'initialized'
- 【TensorFlow问题】AttributeError:'module' object has no attribute 'mul'
- AttributeError: 'NoneType' object has no attribute 'copy' 解决办法
- AttributeError: 'module' object has no attribute 'XXX'
- AttributeError: 'module' object has no attribute 'getpass'
- [置顶] AttributeError: 'module' object has no attribute '_base' 可行解决办法
- AttributeError: 'module' object has no attribute 'VideoWriter_fourcc'
- AttributeError: 'module' object has no attribute 的解决方法