我是靠谱客的博主 搞怪飞鸟,这篇文章主要介绍numpy保存(savez、savez_compressed)后读取报错:too many indices for array,现在分享给大家,希望可以做个参考。
出现的问题如标题所示,result是我之前保存的一个字典:
data = np.load(npz_path)
result = data['result']
result读取出来是类型是:numpy.ndarray
我们需要变成这样就可以正常地对字典进行操作了:
data = np.load(npz_path)
result = data['result'].item()
numpy.ndarray.item()含义:
A copy of the specified element of the array as a suitable Python scalar
最后
以上就是搞怪飞鸟最近收集整理的关于numpy保存(savez、savez_compressed)后读取报错:too many indices for array的全部内容,更多相关numpy保存(savez、savez_compressed)后读取报错:too内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复