InterviewStack.io LogoInterviewStack.io

Activation Functions & Non Linearity Questions

Know common activation functions: ReLU, sigmoid, tanh, softmax, GELU, and Swish. Understand why non-linearity is necessary: stacking any number of purely linear layers collapses to a single linear transformation, eliminating the network's ability to model complex functions. Know the advantages and disadvantages of each activation function (vanishing gradients, dead neurons/dying ReLU, computational cost, output range, saturation). Understand why ReLU remains the default choice in modern architectures despite its simplicity, and when smoother alternatives (GELU, Swish) are preferred in transformer-style models.

MediumTechnical
63 practiced
Implement a PyTorch custom autograd Function or nn.Module for Parametric ReLU (PReLU) where the slope alpha is a learnable parameter. Ensure correct gradient flow, device and dtype awareness, and discuss initialization and potential regularization for alpha. Provide code-level considerations for saving/loading and JIT/ONNX exportability.
HardSystem Design
61 practiced
Design a quantization-friendly, hardware-efficient activation function for a custom accelerator that performs best with integer arithmetic and supports fused ops (conv+bn+act). Describe the mathematical form (e.g., few-segment piecewise-linear), efficient implementation strategies (lookup-tables vs shifts and adds), and the trade-offs between approximation accuracy and hardware complexity. Explain how you'd validate the design end-to-end.
EasyTechnical
56 practiced
Explain why ReLU became the default activation in many modern networks despite being a simple piecewise-linear function. Discuss practical advantages such as induced sparsity, computational cost, gradient propagation benefits, and also describe common failure modes (e.g., dying ReLU) and typical mitigations used in applied machine learning projects.
EasyTechnical
96 practiced
Explain why neural networks require non-linear activation functions. In particular, show with a short mathematical argument why stacking only linear layers (without activation) is equivalent to a single linear transformation. Describe consequences for model expressivity and give a concrete example of a task (e.g., XOR or a simple classification boundary) that cannot be solved by a purely linear network. Conclude with a sentence on how non-linearity enables hierarchy of features.
EasyTechnical
87 practiced
Implement a numerically stable softmax function in Python using NumPy. Signature: def softmax(logits, axis=-1): ... Ensure numerical stability for very large/small logits, support arbitrary axis, and preserve shape. Example: logits = np.array([1000.0, 1001.0]) should return approximately [0.2689, 0.7311]. Explain time and memory complexity of your approach.

Unlock Full Question Bank

Get access to hundreds of Activation Functions & Non Linearity interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.