Cosh#
- class deeptrack.elementwise.Cosh(feature: Feature | None = None, **kwargs: Any)#
Bases:
ElementwiseFeatureApply the hyperbolic cosine function elementwise.
This feature applies xp.cosh to each element in a NumPy array or a PyTorch tensor. It supports both direct input and pipeline composition.
Parameters#
- feature: Feature | None, optional
The input feature to which the hyperbolic cosine 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 Cosh
Use with NumPy directly:
>>> import numpy as np >>> >>> result = Cosh()(np.array([-1.0, 0.0, 1.0])) >>> result array([1.54308063, 1. , 1.54308063])
Use with PyTorch directly:
>>> import torch >>> >>> result = Cosh()(torch.tensor([-1.0, 0.0, 1.0])) >>> result tensor([1.5431, 1.0000, 1.5431])
Use in a pipeline with a NumPy value:
>>> value = dt.Value(value=np.array([-1.0, 0.0, 1.0])) >>> pipeline = value >> Cosh() >>> result = pipeline() >>> result array([1.54308063, 1. , 1.54308063])
Use in a pipeline with a PyTorch value:
>>> value = dt.Value(value=torch.tensor([-1.0, 0.0, 1.0])) >>> pipeline = value >> Cosh() >>> result = pipeline() >>> result tensor([1.5431, 1.0000, 1.5431])
These are equivalent to:
>>> pipeline = Cosh(value)