hw3 prep - carnegie mellon universityece739/2018-spring/lectures/... · 2020. 1. 12. · generative...

28
HW3 Prep 18739

Upload: others

Post on 30-Dec-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: HW3 Prep - Carnegie Mellon Universityece739/2018-spring/lectures/... · 2020. 1. 12. · Generative Model Realistic samples for artwork, super-resolution, colorization, etc. Generative

HW3 Prep18739

Page 2: HW3 Prep - Carnegie Mellon Universityece739/2018-spring/lectures/... · 2020. 1. 12. · Generative Model Realistic samples for artwork, super-resolution, colorization, etc. Generative

Agenda● HW3 is out

○ Due April 17 Before Class

● Review of explanation methods○ Integrated Gradients○ Influence-Directed Explanations○ Their Relationships

● HW 3 Overview● Generative Models

Page 3: HW3 Prep - Carnegie Mellon Universityece739/2018-spring/lectures/... · 2020. 1. 12. · Generative Model Realistic samples for artwork, super-resolution, colorization, etc. Generative

Integrated Gradients

Page 4: HW3 Prep - Carnegie Mellon Universityece739/2018-spring/lectures/... · 2020. 1. 12. · Generative Model Realistic samples for artwork, super-resolution, colorization, etc. Generative

Integrated Gradients

Page 5: HW3 Prep - Carnegie Mellon Universityece739/2018-spring/lectures/... · 2020. 1. 12. · Generative Model Realistic samples for artwork, super-resolution, colorization, etc. Generative

Influence Directed Explanations

Page 6: HW3 Prep - Carnegie Mellon Universityece739/2018-spring/lectures/... · 2020. 1. 12. · Generative Model Realistic samples for artwork, super-resolution, colorization, etc. Generative

Influence Directed Explanations

Page 7: HW3 Prep - Carnegie Mellon Universityece739/2018-spring/lectures/... · 2020. 1. 12. · Generative Model Realistic samples for artwork, super-resolution, colorization, etc. Generative

Comparison between the two● Integrated Gradients:

● Internal / Distributional Influence

Page 8: HW3 Prep - Carnegie Mellon Universityece739/2018-spring/lectures/... · 2020. 1. 12. · Generative Model Realistic samples for artwork, super-resolution, colorization, etc. Generative

Approximation Method for IG

Page 9: HW3 Prep - Carnegie Mellon Universityece739/2018-spring/lectures/... · 2020. 1. 12. · Generative Model Realistic samples for artwork, super-resolution, colorization, etc. Generative

Approximation Method

Page 10: HW3 Prep - Carnegie Mellon Universityece739/2018-spring/lectures/... · 2020. 1. 12. · Generative Model Realistic samples for artwork, super-resolution, colorization, etc. Generative

Approximation Method

Page 11: HW3 Prep - Carnegie Mellon Universityece739/2018-spring/lectures/... · 2020. 1. 12. · Generative Model Realistic samples for artwork, super-resolution, colorization, etc. Generative

HW3 Overview● 3 Parts● Focused Explanation of A Slice

○ What is the influence of neuron 0 towards the output class score C for an instance/Class○ The attribution for a class is the mean attribution of every single instance in the class○ Compare with Integrated Gradients

● Comparative Explanations○ What is the influence of neuron 0 towards the output class score C1-C2 for an instance/Class○ Compare with the explanations using only one class

● Model Compression - Visualizing the essence of a class○ 5 random classes○ Find the neurons with most negative/positive influences○ Mask the slice with selected neurons to create a binary classifier for that class

Page 12: HW3 Prep - Carnegie Mellon Universityece739/2018-spring/lectures/... · 2020. 1. 12. · Generative Model Realistic samples for artwork, super-resolution, colorization, etc. Generative

Theano/Keras Overview● In theano, everything is a variable

○ So to take the gradient of an output (Q) with respect to an input (inpt)○ theano.grad(Q, wrt = inpt)

● How to calculate Q from a model?○ Quantity of interest: the influence of a neuron towards a output class c1 ○ Q = T.take(variable for output, c1, axis=1) (Equivalent to numpy v[:, c1])○ Inpt = variable for input to the layer

● How to get the variable for output/input of a certain layer in a Keras model? ○ Using Theano Backend○ V1 = model.layers[n].output ○ V2 = model.layers[n].output○ W = model.layers[n].get_weights()

Page 13: HW3 Prep - Carnegie Mellon Universityece739/2018-spring/lectures/... · 2020. 1. 12. · Generative Model Realistic samples for artwork, super-resolution, colorization, etc. Generative

Top Neuron● Given an attribution map of slice A (50 neurons), which neuron is the most

influential? ○ 50 * 28 * 28○ Max○ Average(sum)

● Use max for this homework○ A neuron is influential if a feature is influential

Page 14: HW3 Prep - Carnegie Mellon Universityece739/2018-spring/lectures/... · 2020. 1. 12. · Generative Model Realistic samples for artwork, super-resolution, colorization, etc. Generative

Visualization● Saliency Map

○ Compute Gradients of neuron activation wrt input pixels○ Scale pixels of image accordingly

● You can use the same integrated influence measures○ Path-Integrated gradients of neuron activation wrt input pixels○ Scale pixels of image accordingly

Page 15: HW3 Prep - Carnegie Mellon Universityece739/2018-spring/lectures/... · 2020. 1. 12. · Generative Model Realistic samples for artwork, super-resolution, colorization, etc. Generative

Linear Activation Layer

● Avoid overshadowing of class scores○ Softmax tends to decrease the score of the smaller value

Page 16: HW3 Prep - Carnegie Mellon Universityece739/2018-spring/lectures/... · 2020. 1. 12. · Generative Model Realistic samples for artwork, super-resolution, colorization, etc. Generative

Generative Models18739

Page 17: HW3 Prep - Carnegie Mellon Universityece739/2018-spring/lectures/... · 2020. 1. 12. · Generative Model Realistic samples for artwork, super-resolution, colorization, etc. Generative

Supervised vs. Unsupervised learning● Supervised learning● Data (X,y)

○ X -> Data○ Y-> Label

● Goal: Learn a function to map x->y○ Map Image to label

● Examples:○ Classification○ Regression○ Object Detection. etc.

Page 18: HW3 Prep - Carnegie Mellon Universityece739/2018-spring/lectures/... · 2020. 1. 12. · Generative Model Realistic samples for artwork, super-resolution, colorization, etc. Generative

Supervised vs. Unsupervised learning● Supervised learning● Data (X,y)

○ X -> Data○ Y-> Label

● Goal: Learn a function to map x->y○ Map image to (bounding boxes, labels)

● Examples:○ Classification○ Regression○ Object Detection. etc.

Page 19: HW3 Prep - Carnegie Mellon Universityece739/2018-spring/lectures/... · 2020. 1. 12. · Generative Model Realistic samples for artwork, super-resolution, colorization, etc. Generative

Supervised vs. Unsupervised learning● Unsupervised learning● Just Data X, No Labels!● Goal: Learn some underlying

hidden structure of the data ● Examples:

○ Clustering

○ Dimensionality reduction

○ Feature learning

○ Density estimation, etc.

Page 20: HW3 Prep - Carnegie Mellon Universityece739/2018-spring/lectures/... · 2020. 1. 12. · Generative Model Realistic samples for artwork, super-resolution, colorization, etc. Generative

Supervised vs. Unsupervised learning● Unsupervised learning● Just Data X, No Labels!● Goal: Learn some underlying

hidden structure of the data ● Examples:

○ Clustering

○ Dimensionality reduction

○ Feature learning

○ Density estimation, etc.

Page 21: HW3 Prep - Carnegie Mellon Universityece739/2018-spring/lectures/... · 2020. 1. 12. · Generative Model Realistic samples for artwork, super-resolution, colorization, etc. Generative

Supervised vs. Unsupervised learning● Unsupervised learning● Just Data X, No Labels!● Goal: Learn some underlying

hidden structure of the data ● Examples:

○ Clustering

○ Dimensionality reduction

○ Feature learning

○ Density estimation, etc.

Page 22: HW3 Prep - Carnegie Mellon Universityece739/2018-spring/lectures/... · 2020. 1. 12. · Generative Model Realistic samples for artwork, super-resolution, colorization, etc. Generative

Supervised Learning● Data (X,y)

○ X -> Data○ Y-> Label

● Goal: Learn a function to map x->y

○ Map Image to label● Examples:

○ Classification○ Regression○ Object Detection. etc.

Unsupervised Learning

● Just Data X, No Labels!● Goal: Learn some underlying

hidden structure of the data ● Examples:

○ Clustering

○ Dimensionality reduction

○ Feature learning

○ Density estimation, etc.

Page 23: HW3 Prep - Carnegie Mellon Universityece739/2018-spring/lectures/... · 2020. 1. 12. · Generative Model Realistic samples for artwork, super-resolution, colorization, etc. Generative

Advantages of Unsupervised Learning● Training Data is cheap!● Solve unsupervised learning => understand structure of visual world● Representation => Understanding => Explanations

Page 24: HW3 Prep - Carnegie Mellon Universityece739/2018-spring/lectures/... · 2020. 1. 12. · Generative Model Realistic samples for artwork, super-resolution, colorization, etc. Generative

Generative Model

Page 25: HW3 Prep - Carnegie Mellon Universityece739/2018-spring/lectures/... · 2020. 1. 12. · Generative Model Realistic samples for artwork, super-resolution, colorization, etc. Generative

Generative Model

Addresses density estimation, a core problem in unsupervised learning

Several flavors:

● Explicit density estimation: explicitly define and solve for pmodel(x) ● Implicit density estimation: learn model that can sample from pmodel(x) w/o explicitly defining it

Page 26: HW3 Prep - Carnegie Mellon Universityece739/2018-spring/lectures/... · 2020. 1. 12. · Generative Model Realistic samples for artwork, super-resolution, colorization, etc. Generative

Generative Model● Realistic samples for artwork, super-resolution, colorization, etc.

● Generative models of time-series data can be used for simulation and planning (reinforcement learning applications!)

● Training generative models can also enable inference of latent representations that can be useful as general features

Page 27: HW3 Prep - Carnegie Mellon Universityece739/2018-spring/lectures/... · 2020. 1. 12. · Generative Model Realistic samples for artwork, super-resolution, colorization, etc. Generative

Generative Adversarial Network● Estimate the implicity density of image space

● Next Class

Page 28: HW3 Prep - Carnegie Mellon Universityece739/2018-spring/lectures/... · 2020. 1. 12. · Generative Model Realistic samples for artwork, super-resolution, colorization, etc. Generative

References● http://cs231n.stanford.edu/slides/2017/cs231n_2017_lecture13.pdf