From 7b71a7262dbf62f8557bda0ae3e9eb53f851eb3a Mon Sep 17 00:00:00 2001 From: cout0 Date: Mon, 18 Mar 2024 15:28:15 +0800 Subject: [PATCH] fix bugs on house price all_features contains bool type we need convert all to float32 at first for function d2l.tensor --- chapter_multilayer-perceptrons/kaggle-house-price.md | 4 ++-- chapter_multilayer-perceptrons/kaggle-house-price_origin.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/chapter_multilayer-perceptrons/kaggle-house-price.md b/chapter_multilayer-perceptrons/kaggle-house-price.md index 1a4ce5d63..2fb889ea4 100644 --- a/chapter_multilayer-perceptrons/kaggle-house-price.md +++ b/chapter_multilayer-perceptrons/kaggle-house-price.md @@ -284,8 +284,8 @@ all_features.shape ```{.python .input} #@tab all n_train = train_data.shape[0] -train_features = d2l.tensor(all_features[:n_train].values, dtype=d2l.float32) -test_features = d2l.tensor(all_features[n_train:].values, dtype=d2l.float32) +train_features = d2l.tensor(all_features[:n_train].values.astype(np.float32), dtype=d2l.float32) +test_features = d2l.tensor(all_features[n_train:].values.astype(np.float32), dtype=d2l.float32) train_labels = d2l.tensor( train_data.SalePrice.values.reshape(-1, 1), dtype=d2l.float32) ``` diff --git a/chapter_multilayer-perceptrons/kaggle-house-price_origin.md b/chapter_multilayer-perceptrons/kaggle-house-price_origin.md index 58276499d..663bb6c65 100644 --- a/chapter_multilayer-perceptrons/kaggle-house-price_origin.md +++ b/chapter_multilayer-perceptrons/kaggle-house-price_origin.md @@ -338,8 +338,8 @@ representation for training. ```{.python .input} #@tab all n_train = train_data.shape[0] -train_features = d2l.tensor(all_features[:n_train].values, dtype=d2l.float32) -test_features = d2l.tensor(all_features[n_train:].values, dtype=d2l.float32) +train_features = d2l.tensor(all_features[:n_train].values.astype(np.float32), dtype=d2l.float32) +test_features = d2l.tensor(all_features[n_train:].values.astype(np.float32), dtype=d2l.float32) train_labels = d2l.tensor( train_data.SalePrice.values.reshape(-1, 1), dtype=d2l.float32) ```