amatorch.normalization
Functions to normalize tensors in different ways.
Functions
|
Normalize stimuli to have a norm less than or equal to 1. |
|
Normalize stimuli to have a norm less than or equal to 1, normalizing each channel separately. |
- amatorch.normalization.unit_norm(stimuli, c50=0)
Normalize stimuli to have a norm less than or equal to 1.
Channels are normalized by their aggregated offsetted norm (i.e., || sum of squares + c50 ||).
- Parameters:
stimuli (torch.Tensor) – Stimuli tensor of shape (n_stim, n_channels, n_dim).
c50 (torch.Tensor, optional) – Offset constant added to the sum of squares, by default torch.as_tensor(0).
- Returns:
Normalized stimuli tensor of shape (n_stim, n_channels, n_dim).
- Return type:
torch.Tensor
- amatorch.normalization.unit_norm_channels(stimuli, c50=0)
Normalize stimuli to have a norm less than or equal to 1, normalizing each channel separately.
Each channel is normalized separately by its offsetted norm (i.e., sqrt( sum of squares + c50)), and both channels are normalized by the square root of the number of channels.
- Parameters:
stimuli (torch.Tensor) – Stimuli tensor of shape (n_stim, n_channels, n_dim).
c50 (torch.Tensor, optional) – Offset constant added to the sum of squares, by default torch.as_tensor(0).
- Returns:
Normalized stimuli tensor of shape (n_stim, n_channels, n_dim).
- Return type:
torch.Tensor