在2.2.3节转换张量格式中一段代码运行报错“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.”
这是因为pandas对象中数据类型是混合的或不是NumPy可以直接处理的类型(如字符串或Pandas特有的数据类型),则可能不会按预期工作
所以需要先转换成numpy数组格式
X = torch.tensor(inputs.to_numpy(dtype=float))
y = torch.tensor(outputs.to_numpy(dtype=float))
X, y
这样就可以成功了