Exp#

class deeptrack.elementwise.Exp(feature: Feature | None = None, **kwargs: Any)#

Bases: ElementwiseFeature

Apply the exponential function elementwise.

This feature applies xp.exp (NumPy or PyTorch) to each element in the input. It supports both direct input and pipeline composition.

The exponential function computes e**x elementwise.

Parameters#

feature: Feature | None, optional

The input feature to which the exponential 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 Exp

Use with NumPy directly:

>>> import numpy as np
>>> result = Exp()(np.array([-1.0, 0.0, 1.0]))
>>> result
array([0.36787944, 1.        , 2.71828183])

Use with PyTorch directly:

>>> import torch
>>> result = Exp()(torch.tensor([-1.0, 0.0, 1.0]))
>>> result
tensor([0.3679, 1.0000, 2.7183])

Use in a pipeline with a NumPy value:

>>> value = dt.Value(value=np.array([-1.0, 0.0, 1.0]))
>>> pipeline = value >> Exp()
>>> result = pipeline()
>>> result
array([0.36787944, 1.        , 2.71828183])

Use in a pipeline with a PyTorch value:

>>> value = dt.Value(value=torch.tensor([-1.0, 0.0, 1.0]))
>>> pipeline = value >> Exp()
>>> result = pipeline()
>>> result
tensor([0.3679, 1.0000, 2.7183])

These are equivalent to:

>>> pipeline = Exp(value)