mlx.nn.hard_tanh

Contents

mlx.nn.hard_tanh#

class hard_tanh(x, min_val=-1.0, max_val=1.0)#

Applies the HardTanh function.

Applies \(\max(\min(x, \text{max\_val}), \text{min\_val})\) element-wise.