VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes)is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray.
禁止转载!
问题
VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray
原因
这是因为新的numpy版本,将 创建不同长度或形状的列表或元组或ndarray的列表或ndarray元组的功能 会被弃用,虽然能够运行,但是总提示Warning还是很不舒服,况且之后也不能这样用了。
这里先复现一下错误,让大家更好理解:
import numpy as np
test_list=[[12,12],[1,2],[0]]
bboxes = np.array(test_list)
print(bboxes)
VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify ‘dtype=object’ when creating the ndarray.
bboxes = np.array(test_list)
解决办法
- 方法一:使用更早的numpy版本
- 方法二:加上’dtype=object’
bboxes = np.array(test_list,dtype=object)
禁止转载!
版权声明:本文为qq_41917697原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。