- Deep Learning with PyTorch
- Vishnu Subramanian
- 131字
- 2021-06-24 19:16:23
Matrix (2-D tensors)
Most of the structured data is represented in the form of tables or matrices. We will use a dataset called Boston House Prices, which is readily available in the Python scikit-learn machine learning library. The dataset is a numpy array consisting of 506 samples or rows and 13 features representing each sample. Torch provides a utility function called from_numpy(), which converts a numpy array into a torch tensor. The shape of the resulting tensor is 506 rows x 13 columns:
boston_tensor = torch.from_numpy(boston.data)
boston_tensor.size()
Output: torch.Size([506, 13])
boston_tensor[:2]
Output:
Columns 0 to 7
0.0063 18.0000 2.3100 0.0000 0.5380 6.5750 65.2000 4.0900
0.0273 0.0000 7.0700 0.0000 0.4690 6.4210 78.9000 4.9671
Columns 8 to 12
1.0000 296.0000 15.3000 396.9000 4.9800
2.0000 242.0000 17.8000 396.9000 9.1400
[torch.DoubleTensor of size 2x13]
推薦閱讀
- Istio入門與實(shí)戰(zhàn)
- 網(wǎng)絡(luò)服務(wù)器配置與管理(第3版)
- Android NDK Game Development Cookbook
- 電腦組裝與維修從入門到精通(第2版)
- Linux運(yùn)維之道(第2版)
- 嵌入式系統(tǒng)設(shè)計(jì)教程
- 從零開始學(xué)51單片機(jī)C語言
- AMD FPGA設(shè)計(jì)優(yōu)化寶典:面向Vivado/SystemVerilog
- 單片機(jī)系統(tǒng)設(shè)計(jì)與開發(fā)教程
- Hands-On Artificial Intelligence for Banking
- 龍芯自主可信計(jì)算及應(yīng)用
- VMware Workstation:No Experience Necessary
- 基于PROTEUS的電路設(shè)計(jì)、仿真與制板
- Hands-On Deep Learning for Images with TensorFlow
- 電腦橫機(jī)使用與維修