Skip to content

Commit

Permalink
fix bugs on house price
Browse files Browse the repository at this point in the history
all_features contains bool type
we need convert all to float32 at first for function d2l.tensor
  • Loading branch information
cout0 committed Mar 18, 2024
1 parent e6b18cc commit 7b71a72
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions chapter_multilayer-perceptrons/kaggle-house-price.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
```
Expand Down
4 changes: 2 additions & 2 deletions chapter_multilayer-perceptrons/kaggle-house-price_origin.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
```
Expand Down

0 comments on commit 7b71a72

Please sign in to comment.