Train/eval mode, inverted scaling
Easy FundamentalsImplement Dropout regularization from scratch.
• During training: zero each element with probability p, scale remaining by 1/(1-p)
• During eval: return input unchanged (identity)
• Do NOT use nn.Dropout or F.dropout
Implement the function below. Use only basic PyTorch operations.
Use this code to debug before submitting.
Try solving it yourself first! Click below to reveal the solution.
For interactive practice with auto-grading, run TorchCode locally:pip install torch-judge then use check("dropout")
Train/eval mode, inverted scaling