braindecode.modules.Ensure4d#
- class braindecode.modules.Ensure4d(*args, **kwargs)[source]#
Ensure the input tensor has 4 dimensions.
This is a small utility layer that repeatedly adds a singleton dimension at the end until the input has shape
(batch, channels, time, 1).Examples
>>> import torch >>> from braindecode.modules import Ensure4d >>> module = Ensure4d() >>> outputs = module(torch.randn(2, 3, 10)) >>> outputs.shape torch.Size([2, 3, 10, 1])
Methods
- forward(x)[source]#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.