From e98f316ad27530d54ecf87a9bb9abe21bb623914 Mon Sep 17 00:00:00 2001 From: cout0 Date: Mon, 18 Mar 2024 15:51:40 +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 6afe8102..0460a633 100644 --- a/chapter_multilayer-perceptrons/kaggle-house-price.md +++ b/chapter_multilayer-perceptrons/kaggle-house-price.md @@ -210,8 +210,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 ebc44dec..056db1f9 100644 --- a/chapter_multilayer-perceptrons/kaggle-house-price_origin.md +++ b/chapter_multilayer-perceptrons/kaggle-house-price_origin.md @@ -342,8 +342,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) ```