Sin#
- class deeptrack.elementwise.Sin(feature: Feature | None = None, **kwargs: Any)#
Bases:
ElementwiseFeatureApply the sine function elementwise.
This feature applies xp.sin 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 sine 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 Sin
Use with NumPy directly:
>>> import numpy as np >>> >>> result = Sin()(np.array([0, np.pi / 2, np.pi])) >>> result array([0.0000000e+00, 1.0000000e+00, 1.2246468e-16])
Use with PyTorch directly:
>>> import torch >>> >>> result = Sin()(torch.tensor([0, torch.pi / 2, torch.pi])) >>> result tensor([ 0.0000e+00, 1.0000e+00, -8.7423e-08])
Use in a pipeline with a NumPy value:
>>> value = dt.Value(value=np.array([0, np.pi / 2, np.pi])) >>> pipeline = value >> Sin() >>> result = pipeline() >>> result array([0.0000000e+00, 1.0000000e+00, 1.2246468e-16])
Use in a pipeline with a PyTorch value:
>>> value = dt.Value(value=torch.tensor([0, torch.pi / 2, torch.pi])) >>> pipeline = value >> Sin() >>> result = pipeline() >>> result tensor([ 0.0000e+00, 1.0000e+00, -8.7423e-08])
These are equivalent to:
>>> pipeline = Sin(value)