[d2l] section4.10

发布于 2023-07-17  304 次阅读


Problem

在运行以下代码时,会报如下错误:

n_train = train_data.shape[0]
train_features = torch.tensor(all_features[:n_train].values, dtype=torch.float32)
test_features = torch.tensor(all_features[n_train:].values, dtype=torch.float32)
train_labels = torch.tensor(
    train_data.SalePrice.values.reshape(-1, 1), dtype=torch.float32)
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.

原因:同section2.2

解决办法:同section2.2

一条咸鱼
最后更新于 2023-07-17