braindecode.modules.VarLayer#

braindecode.modules.VarLayer = functools.partial(<class 'braindecode.modules.stats.StatLayer'>, <built-in method var of type object>)[source]#

Generic layer to compute a statistical function along a specified dimension. :param stat_fn: A function like torch.mean, torch.std, etc. :type stat_fn: Callable :type dim: int :param dim: Dimension along which to apply the function. :type dim: int :type keepdim: bool, default=True :param keepdim: Whether to keep the reduced dimension. :type keepdim: bool, default=True :type clamp_range: tuple(float, float), optional :param clamp_range: Used only for functions requiring clamping (e.g., log variance). :type clamp_range: tuple(float, float), optional :type apply_log: bool, default=False :param apply_log: Whether to apply log after computation (used for LogVarLayer). :type apply_log: bool, default=False

Examples

>>> import torch
>>> from braindecode.modules import StatLayer
>>> module = StatLayer(stat_fn=torch.mean, dim=-1, keepdim=True)
>>> inputs = torch.randn(2, 3, 10)
>>> outputs = module(inputs)
>>> outputs.shape
torch.Size([2, 3, 1])