如何将numpy.float64数组转换为float64数组?

pn9klfpd  于 2021-09-08  发布在  Java
关注(0)|答案(1)|浏览(402)

我有一个np.array,其中包含其他几个np.array,它们本身包含numpy.float64类型的对象,这导致我的一个方法出现以下问题:

TypeError: can't convert np.ndarray of type numpy.object_. The only supported types are: float64, float32, float16, complex64, complex128, int64, int32, int16, int8, uint8, and bool.

错误具体出现在我的代码的这一行:

self.x = torch.from_numpy(X_train)[train]

有没有办法将np.array的内容转换为常规类型而不是numpy对象?

mqkwyuun

mqkwyuun1#

好的,我调查过了,这是一个数组元素的维数问题。谢谢大家的回答。

相关问题