torchsig.transforms.base_transforms.Lambda¶
- class torchsig.transforms.base_transforms.Lambda(func: Callable, **kwargs)[source]¶
Bases:
Transform- Apply a user-defined lambda as a transform.
Warning: does not automatically update metadata
- func¶
Lambda/function to be used for transform.
- Type:
Callable
Example
>>> from torchsig.transforms.base_transforms import Lambda >>> transform = Lambda(lambda x: x**2) # A transform that squares all inputs.
Methods
Add parent Seedable object and set up RNGs accordingly
get_distributionGets second seed, usually used to seed both torch and numpy generators with slightly different seeds
Seed number generators with given seed.
Initialize torch and numpy number generators, and update its children.
Update bookeeping for signals
Update numpy and torch number generators with parent seed
- __call__(signal: Signal | DatasetSignal) Signal | DatasetSignal[source]¶
Performs transforms
- Parameters:
signal (Any) – Signal to be transformed.
- Raises:
NotImplementedError – Inherited classes must override this method.
- Returns:
Transformed Signal.
- Return type:
Any
- __repr__() str¶
Transform string representation. Should be able to recreate class from this string.
- Returns:
Transform representation.
- Return type:
- get_second_seed(seed: int) int¶
Gets second seed, usually used to seed both torch and numpy generators with slightly different seeds
- update(signal: Signal | DatasetSignal) None¶
Update bookeeping for signals
- Parameters:
signal (Signal | DatasetSignal) – signal to update metadata.
- Raises:
NotImplementedError – Inherited classes must override this method.