Shortcuts

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]. This transform does not support PIL 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 in [0, 1] after adding noise. Default is True.

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources