Shortcuts

Compose

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

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

from torcheeg import transforms

t = transforms.Compose([
    transforms.ToTensor(),
    transforms.Resize(size=(64, 64)),
    transforms.RandomNoise(p=0.1),
    transforms.RandomMask(p=0.1)
])
t(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.

from torcheeg import transforms

t = transforms.Compose([
    transforms.BandDifferentialEntropy(),
    transforms.MeanStdNormalize(),
    transforms.ToGrid(DEAP_CHANNEL_LOCATION_DICT)
])
t(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