public class Tanh<T extends AbstractFloat = Float> extends ElementwiseActivation<T>
Element-wise hyperbolic tangent activation, with outputs in [-1, 1]. Evaluation is stable around zero and for large magnitudes, preserves signed zero, maps infinities to -1/1 and propagates NaN. Backward multiplies upstream by 1 - y * y, using the saved output y during training. No trainable parameters. Supports arbitrary batch sample shapes on CPU and supported GPUs.
layer = klyn.math.nn.layers.Dense<Float>(32, activation="tanh")
output = Tanh<Double>().forward(inputs)