Floor#
- class deeptrack.elementwise.Floor(feature: Feature | None = None, **kwargs: Any)#
Bases:
ElementwiseFeatureApply the floor function elementwise.
This feature applies xp.floor to each element in a NumPy array or a PyTorch tensor. It supports both direct input and pipeline composition.
The floor function returns the greatest integer less than or equal to each element of the input.
Parameters#
- feature: Feature | None, optional
The input feature to which the floor 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 Floor
Use with NumPy directly:
>>> import numpy as np >>> >>> result = Floor()(np.array([-1.7, -0.5, 0.0, 0.5, 1.7])) >>> result array([-2., -1., 0., 0., 1.])
Use with PyTorch directly:
>>> import torch >>> >>> result = Floor()(torch.tensor([-1.7, -0.5, 0.0, 0.5, 1.7])) >>> result tensor([-2., -1., 0., 0., 1.])
Use in a pipeline with a NumPy value:
>>> value = dt.Value(value=np.array([-1.7, -0.5, 0.0, 0.5, 1.7])) >>> pipeline = value >> Floor() >>> result = pipeline() >>> result array([-2., -1., 0., 0., 1.])
Use in a pipeline with a PyTorch value:
>>> value = dt.Value(value=torch.tensor([-1.7, -0.5, 0.0, 0.5, 1.7])) >>> pipeline = value >> Floor() >>> result = pipeline() >>> result tensor([-2., -1., 0., 0., 1.])
These are equivalent to:
>>> pipeline = Floor(value)