Arctanh#
- class deeptrack.elementwise.Arctanh(feature: Feature | None = None, **kwargs: Any)#
Bases:
ElementwiseFeatureApply the inverse hyperbolic tangent function elementwise.
This feature applies xp.arctanh to each element in a NumPy array or a PyTorch tensor. It supports both direct input and pipeline composition.
The input must be within the open interval (-1, 1). Values outside this range will produce NaNs or raise domain errors depending on the backend.
Parameters#
- feature: Feature | None, optional
The input feature to which the hyperbolic arctangent function will be applied. If None, the function is applied directly to the input array or tensor.
Examples#
>>> import deeptrack as dt >>> from deeptrack.elementwise import Arctanh
Use with NumPy directly:
>>> import numpy as np >>> >>> result = Arctanh()(np.array([-0.5, 0.0, 0.5])) >>> result array([-0.54930614, 0. , 0.54930614])
Use with PyTorch directly:
>>> import torch >>> >>> result = Arctanh()(torch.tensor([-0.5, 0.0, 0.5])) >>> result tensor([-0.5493, 0.0000, 0.5493])
Use in a pipeline with a NumPy value:
>>> value = dt.Value(value=np.array([-0.5, 0.0, 0.5])) >>> pipeline = value >> Arctanh() >>> result = pipeline() >>> result array([-0.54930614, 0. , 0.54930614])
Use in a pipeline with a PyTorch value:
>>> value = dt.Value(value=torch.tensor([-0.5, 0.0, 0.5])) >>> pipeline = value >> Arctanh() >>> result = pipeline() >>> result tensor([-0.5493, 0.0000, 0.5493])
These are equivalent to:
>>> pipeline = Arctanh(value)