LayerNorm and RMSNorm
Implement LayerNorm and RMSNorm over the features of each row.
What’s going wrong
Original LLM Architecture lab. Implement the missing behavior in solve(data) and keep the supplied JSON interface. Use Python’s standard library.
Input x contains nonempty feature rows of the same width. weight and bias are feature-size vectors, epsilon > 0. Return layer_norm using population variance, mean centering, weight and bias, and rms_norm using uncentered mean-square and weight only. Add epsilon inside each square root.
Small, well-formed JSON inputs and standard-library Python arithmetic. Keep full precision during computation. The supplied output wrapper rounds results to six decimal places.
Expected behavior
Implement LayerNorm and RMSNorm over the features of each row.
Reproduction
{"x":[[1,3]],"weight":[2,1],"bias":[1,-1],"epsilon":1e-05}{"layer_norm":[[-0.99999,-5e-06]],"rms_norm":[[0.894426,1.341639]]}{"x":[[0,0]],"weight":[2,1],"bias":[1,-1],"epsilon":1e-05}{"layer_norm":[[1,-1]],"rms_norm":[[0,0]]}{"x":[[3,3]],"weight":[2,1],"bias":[1,-1],"epsilon":1e-05}{"layer_norm":[[1,-1]],"rms_norm":[[1.999999,0.999999]]}Before you begin
- Python functions, lists and dictionaries
Need a nudge?
Reveal one investigation hint at a time. Try each clue before opening the next.
Read the report, then sign in to start your investigation.