Shortcuts

Source code for torcheeg.transforms.any.lambd

from typing import Callable, Dict, List

from ..base_transform import BaseTransform


[docs]class Lambda(BaseTransform): r''' Apply a user-defined lambda as a transform. .. code-block:: python from torcheeg import transforms t = transforms.Lambda(targets=['y'], lambda x: x + 1) t(y=1)['y'] >>> 2 Args: targets (list): What data to transform via the Lambda. (default: :obj:`['eeg', 'baseline', 'y']`) lambd (Callable): Lambda/function to be used for transform. .. automethod:: __call__ ''' def __init__(self, lambd: Callable, targets: List[str] = ['eeg', 'baseline', 'y']): super(Lambda, self).__init__() self._targets = targets self.lambd = lambd @property def targets(self) -> Dict[str, Callable]: return {target: self.apply for target in self._targets} def apply(self, *args, **kwargs) -> any: r''' Args: x (any): The input. Returns: any: The transformed output. ''' return self.lambd(args[0])
[docs] def __call__(self, *args, **kwargs) -> Dict[str, any]: r''' Args: x (any): The input. Returns: any: The transformed output. ''' return super().__call__(*args, **kwargs)
@property def repr_body(self) -> Dict: return dict(super().repr_body, **{ 'lambd': self.lambd, 'targets': [...] })
Read the Docs v: latest
Versions
latest
stable
v1.1.2
v1.1.1
v1.1.0
v1.0.11
v1.0.10
v1.0.9
v1.0.8.post1
v1.0.8
v1.0.7
v1.0.6
v1.0.4
v1.0.3
v1.0.2
v1.0.1
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources