# TanhTransform Source: https://www.tensorplay.cn/docs/generated/tensorplay.distributions.TanhTransform.html ```python class tensorplay.distributions.TanhTransform(cache_size: int = 0) ``` Transform via the mapping $y = \tanh(x)$. It is equivalent to ``` ComposeTransform( [ AffineTransform(0.0, 2.0), SigmoidTransform(), AffineTransform(-1.0, 2.0), ] ) ``` However this might not be numerically stable, thus it is recommended to use TanhTransform instead. Note that one should use cache_size=1 when it comes to NaN/Inf values. ```python forward_shape(shape) ``` Infers the shape of the forward computation, given the input shape. Defaults to preserving shape. ```python property inv: Transform ``` Returns the inverse [Transform](/docs/generated/tensorplay.distributions.Transform.html#tensorplay.distributions.Transform) of this transform. This should satisfy t.inv.inv is t. ```python inverse_shape(shape) ``` Infers the shapes of the inverse computation, given the output shape. Defaults to preserving shape.