The Hardtanh Activation Function
Neural Units & Activations DS practice problem on Onlearn.
Difficulty: easy.
Topics: Understanding Piecewise Linear Activation Functions, Hardtanh Thresholding, Numerical Stability, Element-wise Mapping, Saturation Regions, Linear Region Dynamics, Deep Learning Foundations, Neural Network Architecture, Gradient-Based Optimization, Activation Functions, Computational Mathematics, Non-linear Transformations, Vanishing Gradient Mitigation, Piecewise Linear Functions, Input Clamping, Neuron Saturation.
Implement the Hardtanh activation function. The function is defined as f(x) = 1 if x 1, f(x) = 1 if x < 1, and f(x) = x otherwise. Your implementation should handle both scalar values and lists of values.