GaussianNoise¶
- class torchvision.transforms.v2.GaussianNoise(mean: float = 0.0, sigma: float = 0.1, clip=True)[source]¶
Add gaussian noise to images or videos.
The input tensor is expected to be in […, 1 or 3, H, W] format, where … means it can have an arbitrary number of leading dimensions. Each image or frame in a batch will be transformed independently i.e. the noise added to each image will be different.
The input tensor is also expected to be of float dtype in
[0, 1]
, or ofuint8
dtype in[0, 255]
. This transform does not support PIL images.Regardless of the dtype used, the parameters of the function use the same scale, so a
mean
parameter of 0.5 will result in an average value increase of 0.5 units for float images, and an average increase of 127.5 units foruint8
images.- Parameters:
mean (float) – Mean of the sampled normal distribution. Default is 0.
sigma (float) – Standard deviation of the sampled normal distribution. Default is 0.1.
clip (bool, optional) – Whether to clip the values after adding noise, be it to
[0, 1]
for floats or to[0, 255]
foruint8
. Setting this parameter toFalse
may cause unsigned integer overflows with uint8 inputs. Default is True.