Shortcuts

Compose

class torcheeg.transforms.Compose(transforms: List[Callable])[source][source]

Compose several transforms together. Consistent with torchvision.transforms.Compose’s behavior.

transform = Compose([
    ToTensor(),
    Resize(size=(64, 64)),
    RandomNoise(p=0.1),
    RandomMask(p=0.1)
])
transform(eeg=torch.randn(128, 9, 9))['eeg'].shape
>>> (128, 64, 64)

Compose supports transformers with different data dependencies. The above example combines multiple torch-based transformers, the following example shows a sequence of numpy-based transformer.

transform = Compose([
    BandDifferentialEntropy(),
    MeanStdNormalize(),
    ToGrid(DEAP_CHANNEL_LOCATION_DICT)
])
transform(eeg=np.random.randn(32, 128))['eeg'].shape
>>> (128, 9, 9)
Parameters

transforms (list) – The list of transforms to compose.

__call__(*args, **kwargs) any[source][source]
Parameters

x (any) – The input.

Returns

The transformed output.

Return type

any

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