Comments (4)
可能时间有点久了,这里提供一下bug的修复方法
Debug:
这里书上的代码:
n_train = train_data.shape[0]
train_features = torch.tensor(all_features[:n_train].values, dtype=torch.float)
test_features = torch.tensor(all_features[n_train:].values, dtype=torch.float)
train_labels = torch.tensor(train_data.SalePrice.values, dtype=torch.float).view(-1, 1)
原因以及Debug的方法
https://discuss.pytorch.org/t/creating-tensor-typeerror-cant-convert-np-ndarray-of-type-numpy-object/125741
You won’t be able to directly convert it as the object type contains arbitrary or mixed data.
Transform your numpy object to an array first and call torch.from_numpy afterwards.
也就是改成像我这样,先变成numpyarray然后强制类型转化,然后在直接转为tensor
train_features = np.array(all_features[:n_train]).astype(np.float64)
train_features = torch.from_numpy(train_features)
test_features = np.array(all_features[n_train:].values).astype(np.float64)
test_feature
from dive-into-dl-pytorch.
from dive-into-dl-pytorch.
train_features = np.array(all_features[:n_train]).astype(np.float64)
train_features = torch.from_numpy(train_features)
test_features = np.array(all_features[n_train:].values).astype(np.float64)
test_features = torch.from_numpy(test_features)
from dive-into-dl-pytorch.
谢谢
from dive-into-dl-pytorch.
Related Issues (20)
- test
- 4.5.2.1节的书写错误
- 9.4 锚框一节里的画出bbox 的注释书写错误
- 章节 5.6.2 AlexNet 第一个卷积层的comment描述有出入
- 2.2.2节符号错误:应该是+=1而非-=1
- 2.3.3梯度结果问题请教 HOT 1
- 5.6节的描述错误
- 10.4 子词嵌入(fastText)有书写错误
- 10.7.2 torchtext 好像版本更新了,没有stoi属性,且换成新版本get_stoi依旧由于
- 4.4.2 函数报错问题
- 5.6.2 AlexNet最后卷积层的输出大小应该为256*6*6
- 5.2节步幅内容错误
- 3.9节的net中是否要加入softmax HOT 1
- 请问咱们这个pytorch版本有纸质版吗?
- Deprecated use of IPython.display.set_matplotlib_formats
- 现在pytorch的版本已经修改了很多东西希望能对内容进行更新
- 3.5节fashion-mnist.ipynb下载FashionMNIST数据集太慢,有其他载入数据集的办法吗(jupyternotrbook) HOT 1
- test
- Kaggle房价预测调用dl2中的semilogy函数会报错 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dive-into-dl-pytorch.