出现报错:
TypeError: can't convert np.ndarray of type numpy.object_.
The only supported types are: float64, float32, float16, int64, int32, int16, int8, uint8, and bool.
原因:
读入的numpy数组里的元素是object类型,无法将这种类型转换成tensor。
解决:
将numpy数组进行强制类型转换成float类型(或者任何pytorch支持的类型:float64, float32, float16, int64, int32, int16, int8, uint8, and bool)
.astype(float)
可以正常运行!