PyTorchで学ぶIntroduction to Deep Learning
Jasmin Ludolf
Senior Data Science Content Developer, DataCamp
| 問題 | 解決策 |
|---|---|
| データセットが小さい | データを増やす / データ拡張を使う |
| モデル容量が大きすぎる | モデルを小さくする / Dropout を追加 |
| 重みが大きすぎる | Weight decay |
対策:
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()、評価は model.eval() で Dropout を無効化optimizer = optim.SGD(model.parameters(), lr=0.001, weight_decay=0.0001)
weight_decay で制御。通常は小さく設定(例: 0.0001)
PyTorchで学ぶIntroduction to Deep Learning