liveBook · Manning

Gaussian noise

As explained in Deep Learning with JAX

Random noise with a Gaussian distribution added to data, here used to simulate image corruption.

Gaussian noise models random image corruption, such as low-light or high-ISO camera noise. It can also expand an image dataset by creating noisy variants. section 3.1.3 section 9.1.2

A JAX-based augmentation follows a short sequence:

  • Create a PRNG key from a seed, then generate a noise tensor with the image’s shape using jax.random.normal(). section 9.1.2
  • Scale and shift the standard Gaussian values when a different noise range is useful; 0.5 + 0.1*std_noise is one example. section 9.1.2
  • Add the noise tensor to the image, then normalize the result if its values leave the [0.0, 1.0] range. section 9.1.2
Listing 9.5 Generating the random tensor
seed = 42                                                     #1
key = jax.random.PRNGKey(seed)                                #2
 
std_noise = jax.random.normal(key, image.shape)               #3
 
std_noise.min(), std_noise.max()                              #4
 
>>> (Array(-4.170905, dtype=float32), Array(4.259979, dtype=float32)) 
 
noise = 0.5 + 0.1*std_noise                                   #5
 
noise.min(), noise.max()                                      #6
 
>>> (Array(0.08290949, dtype=float32), Array(0.92599785, dtype=float32))    
 
plt.imshow(noise)

The listing shows seeded JAX generation, image-shaped output, observed Gaussian values, and explicit scaling. section 9.1.2

Noisy image augmentation

For an image shaped (200, 200, 3), generate standard Gaussian noise, transform it with noise = 0.5 + 0.1*std_noise, and compute new_image = image + noise. The resulting values may exceed [0.0, 1.0], so min–max normalization restores that range. A separate scikit-image example uses random_noise(img, mode='gaussian'). section 9.1.2 section 3.1.3

How Deep Learning with JAX covers it

How deep it goes
Explains generation, scaling, addition, and normalization, while deferring detailed PRNG internals.
Examples
Uses camera-noise simulation, cat-and-dog augmentation, a shaped image tensor, and a normalized noisy image.
What it assumes
Assumes image arrays and batches, while teaching standard Gaussian generation and seeded JAX keys from the beginning.
What you can do after
Apply it via JAX or scikit-image to generate, add, and normalize Gaussian noise for image augmentation.
How it connects
Connects Gaussian distribution, PRNGs, data augmentation, image processing, and NumPy random generation.

Also explained in

Compare how 3 books explain Gaussian noise →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Deep Learning with JAX. The section links point to the parts of the book it draws on.