image segmentation and visualization · 2021. 6. 7. · visualization by optimization •maximize...

63
Image Segmentation and Visualization Xiaolong Wang

Upload: others

Post on 16-Aug-2021

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

Image Segmentation and Visualization

Xiaolong Wang

Page 2: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

This Class

• Naïve FCN model for Image Segmentation

• Transpose Convolution

• Skip Connection, Hypercolumn

• Visualizing Deep Networks

Slides partially from: http://cs231n.stanford.edu/ https://slazebni.cs.illinois.edu/fall20/

Page 3: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

Segmentation Problem and FCN

Page 4: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

The problem

semantic segmentation instance segmentation

image classification object detection

Page 5: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

The problem

Page 6: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

Semantic Segmentation

Simply staring one pixel is impossible to do the classification

Let’s put in some context!

Page 7: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

Semantic Segmentation

Page 8: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

Semantic Segmentation

Time Consuming!

Page 9: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

Can we process the whole image at one time?

AlexNet input: 227 x 277 x 3

AlexNet Conv5: 13 x 13 x 128

Output ?13 x 13 x 21

Output is too small!

Page 10: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

Can we process the whole image at one time?

AlexNet input: 227 x 277 x 3

AlexNet Conv5: 13 x 13 x 128

Output ?227 x 227 x 21

FC + reshape

Huge number of Parameters for FC: 13 x 13 x 128 x 227 x 227 x 21

Page 11: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

Fully Convolutional Network

Convolution at original image resolution has high computation cost.

Page 12: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

Fully Convolutional Network

D! × H/4 ×W/4 D! × H/4 ×W/4

D" × H/8 ×W/8

Make the feature map small increases the receptive field

Make the feature map larger again increases the resolution

Transpose Convolution

Page 13: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

The FCN paper

Long et al. 2015

Page 14: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

1 x 1 convolutions

Page 15: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

The FCN paper

Page 16: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

The FCN paper

Page 17: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

The upsamling

• Upsampling Layer

• Deconvolution Layer

• Transpose Convolution Layer

Page 18: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

Transpose Convolution

Page 19: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

Recall Convolution3 X 3 convolution with stride 1 and padding 1

Page 20: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

Recall Convolution3 X 3 convolution with stride 1 and padding 1

Page 21: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

Recall Convolution3 X 3 convolution with stride 2 and padding 1

Page 22: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

Recall Convolution3 X 3 convolution with stride 2 and padding 1

Page 23: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

Transpose Convolution3 X 3 transpose convolution, stride 2 and padding 1

Page 24: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

Transpose Convolution3 X 3 transpose convolution, stride 2 and padding 1

Sum over the overlapping region

Page 25: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

1D Transpose Convolution Example

Page 26: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

2D ConvolutionRegular convolution (stride 1, pad 0)

𝑥(( 𝑥() 𝑥(* 𝑥(+

𝑥)( 𝑥)) 𝑥)* 𝑥)+

𝑥*( 𝑥*) 𝑥** 𝑥*+

𝑥+( 𝑥+) 𝑥+* 𝑥++

𝑤(( 𝑤() 𝑤(*

𝑤)( 𝑤)) 𝑤)*

𝑤*( 𝑤*) 𝑤**

𝑧(( 𝑧()

𝑧)( 𝑧))

𝑤!! 𝑤!" 𝑤!# 0 𝑤"! 𝑤"" 𝑤"# 0 𝑤#! 𝑤#" 𝑤## 0 0 0 0 00 𝑤!! 𝑤!" 𝑤!# 0 𝑤"! 𝑤"" 𝑤"# 0 𝑤#! 𝑤#" 𝑤## 0 0 0 00 0 0 0 𝑤!! 𝑤!" 𝑤!# 0 𝑤"! 𝑤"" 𝑤"# 0 𝑤#! 𝑤#" 𝑤## 00 0 0 0 0 𝑤!! 𝑤!" 𝑤!# 0 𝑤"! 𝑤"" 𝑤"# 0 𝑤#! 𝑤#" 𝑤##

𝑥##𝑥#!𝑥#"𝑥#$⋮𝑥$$

𝑧##𝑧#!𝑧!#𝑧!!

Matrix-vector form:

∗ =

=

4x4 input, 2x2 output

Page 27: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

𝑥!!𝑥!"𝑥!#𝑥!$𝑥"!𝑥""𝑥"#𝑥"$𝑥#!𝑥#"𝑥##𝑥#$𝑥$!𝑥$"𝑥$#𝑥$$

𝑧##𝑧#!𝑧!#𝑧!!

𝑤!! 0 0 0𝑤!" 𝑤!! 0 0𝑤!# 𝑤!" 0 00 𝑤!# 0 0𝑤"! 0 𝑤!! 0𝑤"" 𝑤"! 𝑤!" 𝑤!!𝑤"# 𝑤"" 𝑤!# 𝑤!"0 𝑤"# 0 𝑤!#𝑤#! 0 𝑤"! 0𝑤#" 𝑤#! 𝑤"" 𝑤"!𝑤## 𝑤#" 𝑤"# 𝑤""0 𝑤## 0 𝑤"#0 0 𝑤#! 00 0 𝑤#" 𝑤#!0 0 𝑤## 𝑤#"0 0 0 𝑤##

𝑥!! 𝑥!" 𝑥!# 𝑥!$

𝑥"! 𝑥"" 𝑥"# 𝑥"$

𝑥#! 𝑥#" 𝑥## 𝑥#$

𝑥$! 𝑥$" 𝑥$# 𝑥$$

𝑤!! 𝑤!" 𝑤!#

𝑤"! 𝑤"" 𝑤"#

𝑤#! 𝑤#" 𝑤##

𝑧!! 𝑧!"

𝑧"! 𝑧""

=2x2 input, 4x4 output

=∗%

Not an inverse of the original convolution operation, simply reverses dimension change!

SourceTranspose Convolution

Page 28: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

𝑥!!𝑥!"𝑥!#𝑥!$𝑥"!𝑥""𝑥"#𝑥"$𝑥#!𝑥#"𝑥##𝑥#$𝑥$!𝑥$"𝑥$#𝑥$$

𝑧##𝑧#!𝑧!#𝑧!!

𝑤!! 0 0 0𝑤!" 𝑤!! 0 0𝑤!# 𝑤!" 0 00 𝑤!# 0 0𝑤"! 0 𝑤!! 0𝑤"" 𝑤"! 𝑤!" 𝑤!!𝑤"# 𝑤"" 𝑤!# 𝑤!"0 𝑤"# 0 𝑤!#𝑤#! 0 𝑤"! 0𝑤#" 𝑤#! 𝑤"" 𝑤"!𝑤## 𝑤#" 𝑤"# 𝑤""0 𝑤## 0 𝑤"#0 0 𝑤#! 00 0 𝑤#" 𝑤#!0 0 𝑤## 𝑤#"0 0 0 𝑤##

𝑥!! 𝑥!" 𝑥!# 𝑥!$

𝑥"! 𝑥"" 𝑥"# 𝑥"$

𝑥#! 𝑥#" 𝑥## 𝑥#$

𝑥$! 𝑥$" 𝑥$# 𝑥$$

𝑤!! 𝑤!" 𝑤!#

𝑤"! 𝑤"" 𝑤"#

𝑤#! 𝑤#" 𝑤##

𝑧!! 𝑧!"

𝑧"! 𝑧""

𝑥## = 𝑤##𝑧##

=

=∗%

Transpose Convolution

Page 29: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

𝑥!!𝑥!"𝑥!#𝑥!$𝑥"!𝑥""𝑥"#𝑥"$𝑥#!𝑥#"𝑥##𝑥#$𝑥$!𝑥$"𝑥$#𝑥$$

𝑧##𝑧#!𝑧!#𝑧!!

𝑤!! 0 0 0𝑤!" 𝑤!! 0 0𝑤!# 𝑤!" 0 00 𝑤!# 0 0𝑤"! 0 𝑤!! 0𝑤"" 𝑤"! 𝑤!" 𝑤!!𝑤"# 𝑤"" 𝑤!# 𝑤!"0 𝑤"# 0 𝑤!#𝑤#! 0 𝑤"! 0𝑤#" 𝑤#! 𝑤"" 𝑤"!𝑤## 𝑤#" 𝑤"# 𝑤""0 𝑤## 0 𝑤"#0 0 𝑤#! 00 0 𝑤#" 𝑤#!0 0 𝑤## 𝑤#"0 0 0 𝑤##

𝑥!! 𝑥!" 𝑥!# 𝑥!$

𝑥"! 𝑥"" 𝑥"# 𝑥"$

𝑥#! 𝑥#" 𝑥## 𝑥#$

𝑥$! 𝑥$" 𝑥$# 𝑥$$

𝑤!! 𝑤!" 𝑤!#

𝑤"! 𝑤"" 𝑤"#

𝑤#! 𝑤#" 𝑤##

𝑧!! 𝑧!"

𝑧"! 𝑧""

𝑥#! = 𝑤#!𝑧## + 𝑤##𝑧#!

=

Convolve input with flipped filter

=∗%

Transpose Convolution

Page 30: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

𝑥!!𝑥!"𝑥!#𝑥!$𝑥"!𝑥""𝑥"#𝑥"$𝑥#!𝑥#"𝑥##𝑥#$𝑥$!𝑥$"𝑥$#𝑥$$

𝑧##𝑧#!𝑧!#𝑧!!

𝑤!! 0 0 0𝑤!" 𝑤!! 0 0𝑤!# 𝑤!" 0 00 𝑤!# 0 0𝑤"! 0 𝑤!! 0𝑤"" 𝑤"! 𝑤!" 𝑤!!𝑤"# 𝑤"" 𝑤!# 𝑤!"0 𝑤"# 0 𝑤!#𝑤#! 0 𝑤"! 0𝑤#" 𝑤#! 𝑤"" 𝑤"!𝑤## 𝑤#" 𝑤"# 𝑤""0 𝑤## 0 𝑤"#0 0 𝑤#! 00 0 𝑤#" 𝑤#!0 0 𝑤## 𝑤#"0 0 0 𝑤##

𝑥!! 𝑥!" 𝑥!# 𝑥!$

𝑥"! 𝑥"" 𝑥"# 𝑥"$

𝑥#! 𝑥#" 𝑥## 𝑥#$

𝑥$! 𝑥$" 𝑥$# 𝑥$$

𝑤!! 𝑤!" 𝑤!#

𝑤"! 𝑤"" 𝑤"#

𝑤#! 𝑤#" 𝑤##

𝑧!! 𝑧!"

𝑧"! 𝑧""

𝑥#" = 𝑤#"𝑧## + 𝑤#!𝑧#!

=

=∗%

Convolve input with flipped filter

Transpose Convolution

Page 31: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

𝑥!!𝑥!"𝑥!#𝑥!$𝑥"!𝑥""𝑥"#𝑥"$𝑥#!𝑥#"𝑥##𝑥#$𝑥$!𝑥$"𝑥$#𝑥$$

𝑧##𝑧#!𝑧!#𝑧!!

𝑤!! 0 0 0𝑤!" 𝑤!! 0 0𝑤!# 𝑤!" 0 00 𝑤!# 0 0𝑤"! 0 𝑤!! 0𝑤"" 𝑤"! 𝑤!" 𝑤!!𝑤"# 𝑤"" 𝑤!# 𝑤!"0 𝑤"# 0 𝑤!#𝑤#! 0 𝑤"! 0𝑤#" 𝑤#! 𝑤"" 𝑤"!𝑤## 𝑤#" 𝑤"# 𝑤""0 𝑤## 0 𝑤"#0 0 𝑤#! 00 0 𝑤#" 𝑤#!0 0 𝑤## 𝑤#"0 0 0 𝑤##

𝑥!! 𝑥!" 𝑥!# 𝑥!$

𝑥"! 𝑥"" 𝑥"# 𝑥"$

𝑥#! 𝑥#" 𝑥## 𝑥#$

𝑥$! 𝑥$" 𝑥$# 𝑥$$

𝑤!! 𝑤!" 𝑤!#

𝑤"! 𝑤"" 𝑤"#

𝑤#! 𝑤#" 𝑤##

𝑧!! 𝑧!"

𝑧"! 𝑧""

𝑥#$ = 𝑤#"𝑧#!

=

=∗%

Convolve input with flipped filter

Transpose Convolution

Page 32: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

𝑥!!𝑥!"𝑥!#𝑥!$𝑥"!𝑥""𝑥"#𝑥"$𝑥#!𝑥#"𝑥##𝑥#$𝑥$!𝑥$"𝑥$#𝑥$$

𝑧##𝑧#!𝑧!#𝑧!!

𝑤!! 0 0 0𝑤!" 𝑤!! 0 0𝑤!# 𝑤!" 0 00 𝑤!# 0 0𝑤"! 0 𝑤!! 0𝑤"" 𝑤"! 𝑤!" 𝑤!!𝑤"# 𝑤"" 𝑤!# 𝑤!"0 𝑤"# 0 𝑤!#𝑤#! 0 𝑤"! 0𝑤#" 𝑤#! 𝑤"" 𝑤"!𝑤## 𝑤#" 𝑤"# 𝑤""0 𝑤## 0 𝑤"#0 0 𝑤#! 00 0 𝑤#" 𝑤#!0 0 𝑤## 𝑤#"0 0 0 𝑤##

𝑥!! 𝑥!" 𝑥!# 𝑥!$

𝑥"! 𝑥"" 𝑥"# 𝑥"$

𝑥#! 𝑥#" 𝑥## 𝑥#$

𝑥$! 𝑥$" 𝑥$# 𝑥$$

𝑤!! 𝑤!" 𝑤!#

𝑤"! 𝑤"" 𝑤"#

𝑤#! 𝑤#" 𝑤##

𝑧!! 𝑧!"

𝑧"! 𝑧""

𝑥!# = 𝑤!#𝑧## + 𝑤##𝑧!#

=

=∗%

Convolve input with flipped filter

Transpose Convolution

Page 33: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

𝑥!!𝑥!"𝑥!#𝑥!$𝑥"!𝑥""𝑥"#𝑥"$𝑥#!𝑥#"𝑥##𝑥#$𝑥$!𝑥$"𝑥$#𝑥$$

𝑧##𝑧#!𝑧!#𝑧!!

𝑤!! 0 0 0𝑤!" 𝑤!! 0 0𝑤!# 𝑤!" 0 00 𝑤!# 0 0𝑤"! 0 𝑤!! 0𝑤"" 𝑤"! 𝑤!" 𝑤!!𝑤"# 𝑤"" 𝑤!# 𝑤!"0 𝑤"# 0 𝑤!#𝑤#! 0 𝑤"! 0𝑤#" 𝑤#! 𝑤"" 𝑤"!𝑤## 𝑤#" 𝑤"# 𝑤""0 𝑤## 0 𝑤"#0 0 𝑤#! 00 0 𝑤#" 𝑤#!0 0 𝑤## 𝑤#"0 0 0 𝑤##

𝑥!! 𝑥!" 𝑥!# 𝑥!$

𝑥"! 𝑥"" 𝑥"# 𝑥"$

𝑥#! 𝑥#" 𝑥## 𝑥#$

𝑥$! 𝑥$" 𝑥$# 𝑥$$

𝑤!! 𝑤!" 𝑤!#

𝑤"! 𝑤"" 𝑤"#

𝑤#! 𝑤#" 𝑤##

𝑧!! 𝑧!"

𝑧"! 𝑧""

=

=

𝑥!! = 𝑤!!𝑧## + 𝑤!#𝑧#! + 𝑤#!𝑧!# + 𝑤##𝑧!!

∗%

Convolve input with flipped filter

Transpose Convolution

Page 34: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

𝑥!!𝑥!"𝑥!#𝑥!$𝑥"!𝑥""𝑥"#𝑥"$𝑥#!𝑥#"𝑥##𝑥#$𝑥$!𝑥$"𝑥$#𝑥$$

𝑧##𝑧#!𝑧!#𝑧!!

𝑤!! 0 0 0𝑤!" 𝑤!! 0 0𝑤!# 𝑤!" 0 00 𝑤!# 0 0𝑤"! 0 𝑤!! 0𝑤"" 𝑤"! 𝑤!" 𝑤!!𝑤"# 𝑤"" 𝑤!# 𝑤!"0 𝑤"# 0 𝑤!#𝑤#! 0 𝑤"! 0𝑤#" 𝑤#! 𝑤"" 𝑤"!𝑤## 𝑤#" 𝑤"# 𝑤""0 𝑤## 0 𝑤"#0 0 𝑤#! 00 0 𝑤#" 𝑤#!0 0 𝑤## 𝑤#"0 0 0 𝑤##

𝑥!! 𝑥!" 𝑥!# 𝑥!$

𝑥"! 𝑥"" 𝑥"# 𝑥"$

𝑥#! 𝑥#" 𝑥## 𝑥#$

𝑥$! 𝑥$" 𝑥$# 𝑥$$

𝑤!! 𝑤!" 𝑤!#

𝑤"! 𝑤"" 𝑤"#

𝑤#! 𝑤#" 𝑤##

𝑧!! 𝑧!"

𝑧"! 𝑧""

=

=

𝑥!" = 𝑤!"𝑧## + 𝑤!!𝑧#! + 𝑤#"𝑧!# + 𝑤#!𝑧!!

∗%

Convolve input with flipped filter

Transpose Convolution

Page 35: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

Transpose Convolution

input

output

Page 36: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

D! × H/4 ×W/4 D! × H/4 ×W/4

D" × H/8 ×W/8

Page 37: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

Advanced Techniques in Segmentation

Page 38: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

U-Net

Ronneberger et al. 2015

Page 39: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

U-Net

https://phillipi.github.io/pix2pix/

Page 40: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

U-Net and FPN

Lin et al. 2017

Page 41: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

Hypercolumn and Skip Connection

Hariharan et al. 2015

Page 42: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

Hypercolumn and Skip Connection

Bansal et al. 2017

Page 43: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

Dilated convolutions

• Idea: instead of reducing spatial resolution of feature maps, use a large sparse filter

Dilation factor 1 Dilation factor 2 Dilation factor 3

Page 44: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

Dilated convolutions

• Increase the receptive field

input

output

Page 45: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

Visualizing Deep Networks using “Saliency map”

Page 46: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

CAM: Class Activation Maps

Zhou et al. 2016

Page 47: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

CAM: Class Activation Maps

Page 48: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

CAM: Class Activation Maps

Page 49: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

CAM: Class Activation Maps

Page 50: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

CAM: Class Activation Maps

https://www.youtube.com/watch?v=fZvOy0VXWAI&ab_channel=BoleiZhou

Page 51: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

Visualizing Deep Networks by maximizing activation

Page 52: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

Visualization by optimization

• We can synthesize images that maximize activation of a given neuron.

• Find image 𝑥 maximizing target activation 𝑓 𝑥 subject to natural image regularization penalty 𝑅(𝑥):

𝑥∗ = arg max" 𝑓 𝑥 − 𝜆𝑅(𝑥)

Page 53: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

Visualization by optimization• Maximize 𝑓 𝑥 − 𝜆𝑅(𝑥)

• 𝑓 𝑥 is score for a category before softmax• 𝑅(𝑥) is L2 regularization• Perform gradient ascent starting with zero image, add dataset mean

to result

Simonyan et al. 2014

Page 54: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

Visualization by optimization

Compute the Loss

BP the gradients, but do not train the network

Keep adding/aggregating the gradients under constraint 𝑅(𝑥)

Page 55: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

Visualization by optimization

Page 56: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

Google DeepDreamAmplify one layer instead of just one neuron.

Choose an image and a layer in a CNN; repeat:1. Forward: compute activations at chosen layer2. Set gradient of chosen layer equal to its activation

Equivalent to maximizing ∑6 𝑓6)(𝑥)3. Backward: Compute gradient w.r.t. image4. Update image (with some tricks)

Page 57: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization
Page 58: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization
Page 59: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization
Page 60: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization
Page 61: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization
Page 62: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization
Page 63: Image Segmentation and Visualization · 2021. 6. 7. · Visualization by optimization •Maximize "!−-#(!) • !"is score for a category before softmax • #(")is L2 regularization

Next Class

Visualizing Deep Networks