liveBook · Manning

Gaussian noise

As explained in Inside Deep Learning: Math, Algorithms, Models

Random perturbation sampled from a Gaussian distribution and added to data or activations to simulate noise.

Gaussian noise adds random perturbations to training data so an autoencoder learns to reconstruct clean inputs and robust representations. This is useful when real inputs contain camera damage, stains, lighting changes, or shadows, such as in OCR. section 7.4.1

A practical implementation inserts an additive-noise module before the encoder. The module adds noise during training and returns inputs unchanged during evaluation, while the network trains normally with reconstruction loss. section 7.4.1

Noise in an autoencoder

Place AdditiveGaussNoise() after Flatten and before the encoder layers, then compare reconstructions from clean and addNoise(input) data. The amount of Gaussian noise requires dataset-specific tuning, which makes dropout a more convenient alternative in many cases. section 7.4.1

class AdditiveGaussNoise(nn.Module): #1
    def __init__(self):
    super().__init__()

    def forward(self, x): 
        if self.training:            #2 
            return addNoise(x, device=device) 
        else:                        #3 
            return x

Inspect the training-only AdditiveGaussNoise module and its behavior in evaluation mode. section 7.4.1

dnauto_encoder_big = nn.Sequential( 
    nn.Flatten(), 
    AdditiveGaussNoise(),                            #1 
    getLayer(D, D*2), 
    getLayer(D*2, D*2), 
    getLayer(D*2, D*2), 
    nn.Linear(D*2, D*2), 
)

dnauto_decoder_big = nn.Sequential( 
    getLayer(D*2, D*2), 
    getLayer(D*2, D*2), 
    getLayer(D*2, D*2), 
    nn.Linear(D*2, D), 
    View(-1, 1, 28, 28) 
)

dnauto_encode_decode_big = nn.Sequential( 
    dnauto_encoder_big, 
    dnauto_decoder_big 
) 
train_network(dnauto_encode_decode_big, mse_loss, train_loader, 
 test_loader=test_loader, epochs=10, device=device) #2
#1 Only addition! We hope inserting noise here helps.
#2 Trains as usual

Follow the insertion of additive noise into a denoising autoencoder and its ordinary training call. section 7.4.1

How Inside Deep Learning: Math, Algorithms, Models covers it

How deep it goes
Explains the motivation and module placement but defers the Gaussian sampling formula and noise-scale selection details.
Examples
Demonstrates noisy OCR-like images, additive-noise autoencoders, and comparisons between clean, Gaussian-noisy, and dropout-noisy inputs.
What it assumes
Assumes basic autoencoders, training loops, and PyTorch modules while teaching the denoising purpose from practical examples.
What you can do after
Apply it via a training-only PyTorch noise module inside a denoising autoencoder.
How it connects
Connects Gaussian noise with denoising autoencoders, dropout, regularization, reconstruction loss, and OCR.

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 Inside Deep Learning: Math, Algorithms, Models. The section links point to the parts of the book it draws on.