Activations practice problems
13 problems · 0 solved
An activation function is the small nonlinear step applied after every linear layer. Without it, a stack of layers collapses into one big matrix multiply and the network can only learn straight lines. Think of it as a gate that decides how much of each signal passes through. The problems here ask you to write these gates yourself, along with their derivatives for the backward pass. You will implement GELU, the activation used in GPT and BERT, write SiLU and its exact derivative, compute softplus and log-sigmoid without overflow on large inputs, code ELU, mish and hard swish, find the fraction of dead ReLU units, implement sparsemax, and build the gated SwiGLU feed-forward block used in Llama. Start with the Easy problems on GELU, ELU and softplus to get comfortable with numerical stability. Then move to SiLU and sigmoid derivatives, and finish with the GLU family and sparsemax. Interviewers often ask why modern LLMs prefer SwiGLU over ReLU or how to avoid overflow in a sigmoid. Writing these by hand gives you clear answers and helps you debug NaN losses in real training jobs.