在处理数据集的时候出现报错:
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.
train_labels = torch.tensor(
train_data.iloc[0:, [2]].values.reshape(-1, 1), dtype=torch.float32)
这里使用强制转化:.astype(float)
train_labels = torch.tensor(
train_data.iloc[0:, [2]].values.astype(float).reshape(-1, 1), dtype=torch.float32)