cellmap_data.transforms.augment.normalize#
Classes
|
Initialize the normalization transformation. |
- class cellmap_data.transforms.augment.normalize.Normalize(shift=0, scale=0.00392156862745098)[source]#
Initialize the normalization transformation. :param shift: Shift values, before scaling. Defaults to 0. :type shift: float, optional :param scale: Scale values after shifting. Defaults to 1/255. :type scale: float, optional
This is helpful in normalizing the input to the range [0, 1], especially for data saved as uint8 which is scaled to [0, 255].
Example
>>> import torch >>> from cellmap_data.transforms.augment import Normalize >>> x = torch.tensor([[0, 255], [2, 3]], dtype=torch.uint8) >>> Normalize(shift=0, scale=1/255).transform(x, {}) tensor([[0.0000, 1], [0.0078, 0.0118]])