1 of 27

Deep Generative Models

2024

NYCU

Tzer-jen Wei

1-Autoencoders

2 of 27

Learning from wikipedia

  • When?
    • A topic or concept that is well-known and mature
  • Why?
    • Easy to access.
    • Has references.
    • Easy to remember the reference.
  • Cons
    • A bit boring.
    • Feels unprofessional.

3 of 27

4 of 27

Definition

5 of 27

6 of 27

Definition

7 of 27

8 of 27

9 of 27

History

  • first proposed as a nonlinear generalization of principal components analysis (PCA) by Kramer.[1]
  • also been called the autoassociator,[12] or Diabolo network.[13][11]
  • first applications date to early 1990s.[3][14][15]
  • Some of the most powerful AIs in the 2010s involved autoencoders stacked inside deep neural networks.[18]

10 of 27

Why Autoencoder

  • Is it simply learning f(x)=x?
  • Isn’t it too easy?
  • Don’t need labeling. It is self-supervised.

11 of 27

  • autoencoder with a linear encoder and a linear decoder.
  • The components are ordered by their importance.

12 of 27

First Component

13 of 27

Using SVD

14 of 27

15 of 27

Denoising Autoencoder

  • Sometimes, learning f(x)=x is still too easy.
  • Why not make it more challenging?

​

Two assumptions:

  • Higher level representations are relatively stable and robust to the corruption of the input;
  • To perform denoising well, the model needs to extract features that capture useful structure in the input distribution.

16 of 27

17 of 27

Application

  • Dimensionality reduction
  • Information retrieval
  • Anomaly detection
  • Image processing

18 of 27

19 of 27

Example Code

20 of 27

Dataloader

21 of 27

Encoder

22 of 27

Decoder

23 of 27

24 of 27

25 of 27

26 of 27

27 of 27

Homework

Use autoencoder to generate the following datasets for different latent dimensions.

  • mnist, latent dim=64, 32, 4
  • fashion mnist, latent dim=64, 32, 4

For each of the above case,

  • Calculate mean square error and L1 error for training and testing(you can choose any loss function).
  • Show 16 reconstructed image for 16 random images from training dataset as a 4x4 grid
  • Show 16 reconstructed image for 16 random images from testing dataset as a 4x4 grid

Submit your work in a single jupyter notebook, using tensorflow, pytorch.