- GPU加速训练
- Dropout缓解过拟合
- 批标准化
- 对数据集进行更改
- 对模型进行更改
两种方法:
1. .cuda()
2. device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
.to(device)
Dropout缓解过拟合
net_dropped = torch.nn.Sequential(
torch.nn.Linear(1, N_HIDDEN),
torch.nn.Dropout(0.5), # drop 50% of the neuron
torch.nn.ReLU(),
torch.nn.Linear(N_HIDDEN, N_HIDDEN),
torch.nn.Dropout(0.5), # drop 50% of the neuron
torch.nn.ReLU(),
torch.nn.Linear(N_HIDDEN, 1),
)
批标准化
- nn.BatchNorm1d(num_features)
- nn.BatchNorm2d(num_features)
- nn.BatchNorm3d(num_features)



