Skip to content

Transforms

eva.data.transforms.ArrayToTensor

Converts a numpy array to a torch tensor.

eva.data.transforms.ArrayToFloatTensor

Bases: ArrayToTensor

Converts a numpy array to a torch tensor and casts it to float.

eva.data.transforms.Pad2DTensor

Pads a 2D tensor to a fixed dimension accross the first dimension.

Parameters:

Name Type Description Default
pad_size int

The size to pad the tensor to. If the tensor is larger than this size, no padding will be applied.

required
pad_value int | float

The value to use for padding.

float('-inf')
Source code in src/eva/core/data/transforms/padding/pad_2d_tensor.py
def __init__(self, pad_size: int, pad_value: int | float = float("-inf")):
    """Initialize the transformation.

    Args:
        pad_size: The size to pad the tensor to. If the tensor is larger than this size,
            no padding will be applied.
        pad_value: The value to use for padding.
    """
    self._pad_size = pad_size
    self._pad_value = pad_value

eva.data.transforms.SampleFromAxis

Samples n_samples entries from a tensor along a given axis.

Parameters:

Name Type Description Default
n_samples int

The number of samples to draw.

required
seed int

The seed to use for sampling.

42
axis int

The axis along which to sample.

0
Source code in src/eva/core/data/transforms/sampling/sample_from_axis.py
def __init__(self, n_samples: int, seed: int = 42, axis: int = 0):
    """Initialize the transformation.

    Args:
        n_samples: The number of samples to draw.
        seed: The seed to use for sampling.
        axis: The axis along which to sample.
    """
    self._seed = seed
    self._n_samples = n_samples
    self._axis = axis
    self._generator = self._get_generator()