Nhập môn Deep Learning với PyTorch
Jasmin Ludolf
Senior Data Science Content Developer, DataCamp
| Vấn đề | Giải pháp |
|---|---|
| Tập dữ liệu chưa đủ lớn | Thu thập thêm / tăng cường dữ liệu |
| Mô hình quá lớn (dư năng lực) | Giảm kích thước / thêm dropout |
| Trọng số quá lớn | Weight decay |
Chiến lược:
model = nn.Sequential(nn.Linear(8, 4),
nn.ReLU(),
nn.Dropout(p=0.5))
features = torch.randn((1, 8))
print(model(features))
tensor([[1.4655, 0.0000, 0.0000, 0.8456]], grad_fn=<MulBackward0>)
model.train() để huấn luyện và model.eval() để tắt dropout khi đánh giáoptimizer = optim.SGD(model.parameters(), lr=0.001, weight_decay=0.0001)
weight_decay trong optimizer, thường là số nhỏ (ví dụ 0.0001)
Nhập môn Deep Learning với PyTorch