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:
TransformMulti-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.
- 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.
Examples using nidl.transforms.MultiViewsTransform¶
Self-Supervised Contrastive Learning with SimCLR on MNIST
Visualization of metrics during training of PyTorch-Lightning models
Weakly Supervised Contrastive Learning with y-Aware