Normalization, running stats, affine transform
Medium FundamentalsImplement Layer Normalization from scratch.
where \mu and \sigma^2 are computed over the last dimension.
• Do NOT use F.layer_norm or torch.nn.LayerNorm
• Normalize over the last dimension only
• Must support autograd
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("layernorm")
Normalization, running stats, affine transform