bugger.
All challenges/Pythoneasyllm-activations-v1
THE INVESTIGATION

Activation functions and local gradients

Implement activation values and their first derivatives.

LLM ArchitectureLLM training

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 is a list of finite values bounded by 10,000 and activation is sigmoid, tanh, relu, gelu or softplus. Use exact GELU x·Phi(x) with Phi from erf and the standard normal density in its derivative. ReLU has derivative zero at zero. Return values and gradients in input order.

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 activation values and their first derivatives.

Reproduction

01 GELU includes the derivative of its CDF
{"activation":"gelu","x":[-2,0,2]}
{"values":[-0.0455,0,1.9545],"gradients":[-0.085232,0.5,1.085232]}
02 ReLU on nonpositive values
{"activation":"relu","x":[-2,0]}
{"values":[0,0],"gradients":[0,0]}
03 Empty input
{"activation":"sigmoid","x":[]}
{"values":[],"gradients":[]}

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.

    The bug is intentional. Run the starter code to see it fail, then work toward a fix. Difficulty is provisional.
    Read-only preview
    Ready when you are
    Every fix starts with a failing test.

    Read the report, then sign in to start your investigation.