Introduction to Deep Learning with PyTorch
Jasmin Ludolf
Senior Data Science Content Developer, DataCamp
Problem | Solutions |
---|---|
Dataset is not large enough | Get more data / use data augmentation |
Model has too much capacity | Reduce model size / add dropout |
Weights are too large | Weight decay |
Strategies:
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()
for training and model.eval()
to disable dropout during evaluationoptimizer = optim.SGD(model.parameters(), lr=0.001, weight_decay=0.0001)
weight_decay
parameter in the optimizer, typically set to a small value (e.g., 0.0001)Introduction to Deep Learning with PyTorch