Basics for Convolutional Neural Network...Image Classification 28 x 28 = [28]2 CU DU CU [28] 2[14]...

25
Basics for Convolutional Neural Network CSE 455 Beibin Li 2020-05-26

Transcript of Basics for Convolutional Neural Network...Image Classification 28 x 28 = [28]2 CU DU CU [28] 2[14]...

Page 1: Basics for Convolutional Neural Network...Image Classification 28 x 28 = [28]2 CU DU CU [28] 2[14] [14] 2 DU CU [7] [7] 2 GAP FC [1] Cat CU DU GAP Convolutional FC Unit Down-sampling

Basics for

Convolutional Neural

NetworkCSE 455

Beibin Li

2020-05-26

Page 2: Basics for Convolutional Neural Network...Image Classification 28 x 28 = [28]2 CU DU CU [28] 2[14] [14] 2 DU CU [7] [7] 2 GAP FC [1] Cat CU DU GAP Convolutional FC Unit Down-sampling

CNN

Page 3: Basics for Convolutional Neural Network...Image Classification 28 x 28 = [28]2 CU DU CU [28] 2[14] [14] 2 DU CU [7] [7] 2 GAP FC [1] Cat CU DU GAP Convolutional FC Unit Down-sampling

Convolution OperationNowadays, we learn kernels from the data.

Page 4: Basics for Convolutional Neural Network...Image Classification 28 x 28 = [28]2 CU DU CU [28] 2[14] [14] 2 DU CU [7] [7] 2 GAP FC [1] Cat CU DU GAP Convolutional FC Unit Down-sampling

Learning

● Details:

● https://www.slideshare.net/EdwinEfranJimnezLepe/example-feedforward-backpropagation

● https://medium.com/@2017csm1006/forward-and-backpropagation-in-convolutional-neural-network-4dfa96d7b37e

Page 5: Basics for Convolutional Neural Network...Image Classification 28 x 28 = [28]2 CU DU CU [28] 2[14] [14] 2 DU CU [7] [7] 2 GAP FC [1] Cat CU DU GAP Convolutional FC Unit Down-sampling

Pooling

e.g. kernel size = 2, stride = 2 for both

width and height.

The kernel size for pooling can be an

even number.

Page 6: Basics for Convolutional Neural Network...Image Classification 28 x 28 = [28]2 CU DU CU [28] 2[14] [14] 2 DU CU [7] [7] 2 GAP FC [1] Cat CU DU GAP Convolutional FC Unit Down-sampling

CNN StructuresImage Classification

Page 7: Basics for Convolutional Neural Network...Image Classification 28 x 28 = [28]2 CU DU CU [28] 2[14] [14] 2 DU CU [7] [7] 2 GAP FC [1] Cat CU DU GAP Convolutional FC Unit Down-sampling

Image Classification

28 x 28 = [28]2

CU DU CU

[28]2 [14]2 [14]2

DU CU

[7]2 [7]2

GAP FC

[1]2

Cat

CU

DU GAP

FCConvolutional

Unit

Down-sampling Unit

Fully-connectedOr Linear Layer

Global Avg.Pooling

Page 8: Basics for Convolutional Neural Network...Image Classification 28 x 28 = [28]2 CU DU CU [28] 2[14] [14] 2 DU CU [7] [7] 2 GAP FC [1] Cat CU DU GAP Convolutional FC Unit Down-sampling

Convolutional Unit (CU) - VGG

3x3 Conv Layer

3x3 Conv Layer

Image Source (Inception): Szegedy, Christian, et al. "Rethinking theinception architecture for computer vision." CVPR. 2016.

Page 9: Basics for Convolutional Neural Network...Image Classification 28 x 28 = [28]2 CU DU CU [28] 2[14] [14] 2 DU CU [7] [7] 2 GAP FC [1] Cat CU DU GAP Convolutional FC Unit Down-sampling

Basic Block in ResNet

3x3 Conv Layer

3x3 Conv Layer

ResNet: He, Kaiming, et al. "Deep residual learningfor image recognition." CVPR. 2016.

• Residual Connection• Element-wise addition of input and output• Improves gradient flow and accuracy• In ResNet-18 and ResNet-34• Still computationally expensive

• Hard to train very deep networks (> 100 layers)

Page 10: Basics for Convolutional Neural Network...Image Classification 28 x 28 = [28]2 CU DU CU [28] 2[14] [14] 2 DU CU [7] [7] 2 GAP FC [1] Cat CU DU GAP Convolutional FC Unit Down-sampling

Bottleneck in ResNet

3x3 Depth-Conv Layer

1x1 Conv Layer

• Used in ResNet-50, ResNet-101, ResNet-152, etc...• Computationally Efficient

Influence:• Bottleneck unit with Depth-wise convs

• MobileNetv2• ShuffleNetv2

• MobileNetv2: Sandler, Mark, et al. "Mobilenetv2: Inverted residuals andlinear bottlenecks." CVPR, 2018.

• ShuffleNetv2: Ma, Ningning, et al. "Shufflenet v2: Practical guidelines forefficient cnn architecture design." ECCV, 2018.

1x1 Conv Layer

Page 11: Basics for Convolutional Neural Network...Image Classification 28 x 28 = [28]2 CU DU CU [28] 2[14] [14] 2 DU CU [7] [7] 2 GAP FC [1] Cat CU DU GAP Convolutional FC Unit Down-sampling

CNN StructuresSemantic Segmentation

Page 12: Basics for Convolutional Neural Network...Image Classification 28 x 28 = [28]2 CU DU CU [28] 2[14] [14] 2 DU CU [7] [7] 2 GAP FC [1] Cat CU DU GAP Convolutional FC Unit Down-sampling
Page 13: Basics for Convolutional Neural Network...Image Classification 28 x 28 = [28]2 CU DU CU [28] 2[14] [14] 2 DU CU [7] [7] 2 GAP FC [1] Cat CU DU GAP Convolutional FC Unit Down-sampling

Encoder-Decoder

Page 14: Basics for Convolutional Neural Network...Image Classification 28 x 28 = [28]2 CU DU CU [28] 2[14] [14] 2 DU CU [7] [7] 2 GAP FC [1] Cat CU DU GAP Convolutional FC Unit Down-sampling

Encoder-Decoder in Semantic Segmentation

CU DU CU DU CU

UUCUUUCU

CU DU GAPFCConvolutional

UnitDown-sampling

UnitFully-connectedOr Linear Layer

Global Avg.Pooling

UUUp-sampling

Unit

Page 15: Basics for Convolutional Neural Network...Image Classification 28 x 28 = [28]2 CU DU CU [28] 2[14] [14] 2 DU CU [7] [7] 2 GAP FC [1] Cat CU DU GAP Convolutional FC Unit Down-sampling

U-Net

CU DU GAPFCConvolutional

UnitDown-sampling

UnitFully-connectedOr Linear Layer

Global Avg.Pooling

UUUp-sampling

Unit

CU DU CU DU CU

UUCUUUCU

Page 16: Basics for Convolutional Neural Network...Image Classification 28 x 28 = [28]2 CU DU CU [28] 2[14] [14] 2 DU CU [7] [7] 2 GAP FC [1] Cat CU DU GAP Convolutional FC Unit Down-sampling

Deep Learning Libraries

Page 17: Basics for Convolutional Neural Network...Image Classification 28 x 28 = [28]2 CU DU CU [28] 2[14] [14] 2 DU CU [7] [7] 2 GAP FC [1] Cat CU DU GAP Convolutional FC Unit Down-sampling

Homework 6

Page 18: Basics for Convolutional Neural Network...Image Classification 28 x 28 = [28]2 CU DU CU [28] 2[14] [14] 2 DU CU [7] [7] 2 GAP FC [1] Cat CU DU GAP Convolutional FC Unit Down-sampling

Homework 6

Convolutional Neural Networks

In PyTorch(Optional Homework)

Due: June/4

Page 19: Basics for Convolutional Neural Network...Image Classification 28 x 28 = [28]2 CU DU CU [28] 2[14] [14] 2 DU CU [7] [7] 2 GAP FC [1] Cat CU DU GAP Convolutional FC Unit Down-sampling

Neural Network (Q1)

Page 20: Basics for Convolutional Neural Network...Image Classification 28 x 28 = [28]2 CU DU CU [28] 2[14] [14] 2 DU CU [7] [7] 2 GAP FC [1] Cat CU DU GAP Convolutional FC Unit Down-sampling

Convolutional Neural Network (Q2)

Conv

Pool

FC

Cross Entropy

Page 21: Basics for Convolutional Neural Network...Image Classification 28 x 28 = [28]2 CU DU CU [28] 2[14] [14] 2 DU CU [7] [7] 2 GAP FC [1] Cat CU DU GAP Convolutional FC Unit Down-sampling

Yellow or Blue?

Page 22: Basics for Convolutional Neural Network...Image Classification 28 x 28 = [28]2 CU DU CU [28] 2[14] [14] 2 DU CU [7] [7] 2 GAP FC [1] Cat CU DU GAP Convolutional FC Unit Down-sampling

Color Normalization (Q3)

Page 23: Basics for Convolutional Neural Network...Image Classification 28 x 28 = [28]2 CU DU CU [28] 2[14] [14] 2 DU CU [7] [7] 2 GAP FC [1] Cat CU DU GAP Convolutional FC Unit Down-sampling

Deep Convolutional Neural Network (Q4)

Page 24: Basics for Convolutional Neural Network...Image Classification 28 x 28 = [28]2 CU DU CU [28] 2[14] [14] 2 DU CU [7] [7] 2 GAP FC [1] Cat CU DU GAP Convolutional FC Unit Down-sampling

Make the Design More Flexible

Input:

[8, 16, 32, "pool"]

Page 25: Basics for Convolutional Neural Network...Image Classification 28 x 28 = [28]2 CU DU CU [28] 2[14] [14] 2 DU CU [7] [7] 2 GAP FC [1] Cat CU DU GAP Convolutional FC Unit Down-sampling

Data Augmentation (Q5)

Random Affine Transformation