autoencoders - purdue university

14
Aug 9 th , 2018 Slide 1 Autoencoders

Upload: others

Post on 16-Oct-2021

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Autoencoders - Purdue University

Aug 9th, 2018 Slide 1

Autoencoders

Page 2: Autoencoders - Purdue University

Aug 9th, 2018 Slide 2

Autoencoders

• Autoencoders are neural networks that are trained to copy their input to their output

Autoencoder

Page 3: Autoencoders - Purdue University

Aug 9th, 2018 Slide 3

Autoencoders

• But why do this ?– The goal is learn a hidden representation(typically

lower dimensional) of the input

Autoencoder

Page 4: Autoencoders - Purdue University

Aug 9th, 2018 Slide 4

Autoencoders• But Why do this ?– The goal is to learn a hidden representation(typically

lower dimensional) of the input– This hidden representation could act a feature or

lower dimensional representation of input data

Encoder Network

DecoderNetwork

Low dimensionalhidden representation

Page 5: Autoencoders - Purdue University

Aug 9th, 2018 Slide 5

Autoencoders

• They consist of an encoder function 𝒉 𝒙 which takes an input 𝒙 to the hidden representation 𝒛 and a decoder function 𝒈 𝒛 that maps the hidden representation 𝒛 to the input 𝒙.

Encoder Network

DecoderNetwork

𝒙𝒉(𝒙) 𝒛 g(𝒛) 𝒙'

m𝑖𝑛+,-

. 𝒙' − 𝒙 𝟐�

Page 6: Autoencoders - Purdue University

Aug 9th, 2018 Slide 6

Autoencoders• Autoencoders can be thought of as a non linear PCA

𝒙 𝑾 𝒛 𝑾𝑻 𝒙'

m𝑖𝑛𝑾

. 𝒙' − 𝒙 𝟐�

𝟐

m𝑖𝑛𝑾

.(𝑾𝑻�

𝑾𝒙 − 𝒙)𝟐

PCA

Projection along d (d < n) principal components

𝑾𝑻𝑾 = 𝑰

𝒙𝝐𝑹𝒏

𝒛 ∈ 𝑹𝒅

Page 7: Autoencoders - Purdue University

Aug 9th, 2018 Slide 7

Autoencoders• Autoencoders can be thought of as a non linear PCA

𝒙 h(𝒙) 𝒛 𝒈(𝒛) 𝒙'

m𝑖𝑛+,-

. 𝒙' − 𝒙 𝟐�

m𝑖𝑛𝒉,𝒈

.(𝒈(𝒉 𝒙 )�

− 𝒙)𝟐

Non linear PCA

Lower dimensional representation

𝒙𝝐𝑹𝒏

𝒛 ∈ 𝑹𝒅

Page 8: Autoencoders - Purdue University

Aug 9th, 2018 Slide 8

Autoencoders

• Autoencoders are trained using gradient descent (or some other optimization algorithm) on the loss function through backprop just like any other cnn

Page 9: Autoencoders - Purdue University

Aug 9th, 2018 Slide 9

Example

• In this session we will build an autoencoder that learns to learn a lower dimensional representation of mnist digits.

Page 10: Autoencoders - Purdue University

Aug 9th, 2018 Slide 10

Example

Encoder Network

128 dim

784 dim

DecoderNetwork

Page 11: Autoencoders - Purdue University

Aug 9th, 2018 Slide 11

Autoencoder Structure

Den

se la

yer 1

Den

se la

yer 2

Den

se la

yer 3

Den

se la

yer 4

784 dim

256 dim

128 dim

256 dim

784 dim

Hidden representation : 𝒛

ENCODER DECODER

Flatten Reshape

Page 12: Autoencoders - Purdue University

Aug 9th, 2018 Slide 12

Autoencoder Structure

• Dense layer 1 : transforms input of dim 784 to 256 so it will have a weight matrix of (256x784) and bias vector of length 256

• Dense layer 3 : transforms input of dim 128 to 256 so it will have a weight matrix of (256x128) and bias vector of length 256

• Assumption : Every dense layer has a sigmoid activation function

Page 13: Autoencoders - Purdue University

Aug 9th, 2018 Slide 13

Autoencoder Architecture

• For the demo we will use an l2 loss function and rmspropas optimizer.

Page 14: Autoencoders - Purdue University

Aug 9th, 2018 Slide 14

Assignment

• In the demo we used an l2 loss. Try running the code with an l1 loss and see the results.

• Once you are done with this construct an autoencoder of the with the following encoder architecture

• After constructing the autoencoder train it with l2 and l1 loss and visualize the results. If the results are not good try changing the hyperparameters like learning rate, optimizer etc to see if the results improve

Den

se la

yer 1

Den

se la

yer 2

256 dim

128 dim

Flatten 32 dim

Den

se la

yer 3

Hidden representation : 𝒛