TypeError: can‘t convert np.ndarray of type numpy.object_.解决办法
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.解决办法
·
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.解决办法
问题描述
在讲dataframe中的列表数据制作成数据集是,报错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.
原来的数据格式是这样的:样本有1044列,每一条数据有1024个采样点,每一行代表一个样本。
解决办法
原来的
dat_dict["samples"] = torch.from_numpy(X_train)
修改之后
dat_dict["samples"] = torch.tensor([item for item in X_train])
最终转换成这种形式
就成功了!
更多推荐
已为社区贡献9条内容
所有评论(0)