Note

This page is a reference documentation. It only explains the class signature, and not how to use it. Please refer to the user guide for the big picture.

nidl.transforms.MultiViewsTransform

class nidl.transforms.MultiViewsTransform(transforms, n_views=None, **kwargs)[source]

Bases: Transform

Multi-views transformation.

It generates several “views” of the same input data, i.e. it applies transformations (usually stochastic) multiple times to the input.

Parameters:
transforms: Callable or Sequence of Callable

Transformation or sequence of transformations to be applied. If a single transform is given, it generates n_views of the same input using the same transformation applied n_views times. If a sequence is given, it applies this sequence of transforms to the input in the same order.

n_views: int or None, default=None

Number of views to generate if transforms is a Transform. If n_views != 1 and transforms is a sequence, a ValueError is raised. If None, it is set to 1 if transforms is a Transform and ignored otherwise.

kwargs: dict

Additional keyword arguments given to Transform.

Returns:
data: tuple of array or torch.Tensor

Tuple of transformed data.

Notes

The data are not parsed by this transformation. It should be handled elsewhere.

__init__(transforms, n_views=None, **kwargs)[source]
apply_transform(x, **kwargs)[source]

Apply the transformation on the data parsed by parse_data. This should be implemented in all subclasses.

Parameters:
data_parsed: Any

Input data with type and shape already checked.

*args: Any

Additional positional arguments.

**kwargs: dict

Additional keyword arguments.

Returns:
data: Any

The transformed data.

parse_data(data)[source]

Data are not parsed here.

Examples using nidl.transforms.MultiViewsTransform

Model probing callback of embedding estimators

Model probing callback of embedding estimators

Self-Supervised Contrastive Learning with SimCLR on MNIST

Self-Supervised Contrastive Learning with SimCLR on MNIST

Self-Supervised Learning with Barlow Twins

Self-Supervised Learning with Barlow Twins

Visualization of metrics during training of PyTorch-Lightning models

Visualization of metrics during training of PyTorch-Lightning models

Weakly Supervised Contrastive Learning with y-Aware

Weakly Supervised Contrastive Learning with y-Aware