8 Dataset and DataLoader
0 Revision
- Manual data feed
1 | xy=np.loadtxt('data/diabetes.csv.gz', delimiter=',', dtype=np.float32) |
1 Terminology
- Epoch: 一次训练循环
- Batch_Size: batch中样本的数量
- Iteration: batch的数量
1 | # Training cycle |
2 Dataset & DataLoader

1 | import torch |
- 数据集读取方法:
- init全部读取到内存
- init读取文件名列表,getitem根据索引读取文件
- Windows直接进行多进程读取会报错,需要在if name == ‘main’:中运行
3 Example Implementation
1 | class DiabetesDataset(Dataset): |
4 The following dataset loaders are available
Example: MNIST
1 | import torch |
5 Exercise
5.1
- Build DataLoader for Titanic dataset
- Build a classifier using the DataLoader