TypeError: can‘t convert np.ndarray of type numpy.object_.The only supported types are:
由于读入的numpy数组里的元素是object类型,无法将这种类型转换成tensor。
所以,将numpy数组进行强制类型转换成float类型(或者任何pytorch支持的类型:float64, float32, float16, int64, int32, int16, int8, uint8, and bool)即可。
trainx = trainx.astype(float) # numpy强制类型转换