HardTanhΒΆ

Applies the HardTanh function.

Abstract Signature:

HardTanh(x: Tensor, min_val: float = -1.0, max_val: float = 1.0)

PyTorch

API: torch.nn.functional.hardtanh
Strategy: Direct Mapping

JAX (Core)

API: jax.nn.hard_tanh
Strategy: Direct Mapping

Keras

API: keras.ops.clip
Strategy: Macro 'keras.ops.clip({x}, -1.0, 1.0)'

TensorFlow

API: tf.clip_by_value
Strategy: Macro 'tf.clip_by_value({x}, -1.0, 1.0)'

Apple MLX

API: mlx.nn.hard_tanh
Strategy: Direct Mapping

Flax NNX

API: flax.nnx.HardTanh
Strategy: Direct Mapping