Deep learning 4.5. Pooling Fran cois Fleuret - - PowerPoint PPT Presentation

deep learning 4 5 pooling
SMART_READER_LITE
LIVE PREVIEW

Deep learning 4.5. Pooling Fran cois Fleuret - - PowerPoint PPT Presentation

Deep learning 4.5. Pooling Fran cois Fleuret https://fleuret.org/ee559/ Nov 2, 2020 The historical approach to compute a low-dimension signal ( e.g. a few scores) from a high-dimension one ( e.g. an image) was to use pooling operations. Such


slide-1
SLIDE 1

Deep learning 4.5. Pooling

Fran¸ cois Fleuret https://fleuret.org/ee559/ Nov 2, 2020

slide-2
SLIDE 2

The historical approach to compute a low-dimension signal (e.g. a few scores) from a high-dimension one (e.g. an image) was to use pooling operations. Such an operation aims at grouping several activations into a single “more meaningful” one.

Fran¸ cois Fleuret Deep learning / 4.5. Pooling 1 / 7

slide-3
SLIDE 3

The most standard type of pooling is the max-pooling, which computes max values over non-overlapping blocks. For instance in 1d with a kernel of size 2: 1 4

  • 1

2

  • 2

1 3 3 1

Input r w

Fran¸ cois Fleuret Deep learning / 4.5. Pooling 2 / 7

slide-4
SLIDE 4

The most standard type of pooling is the max-pooling, which computes max values over non-overlapping blocks. For instance in 1d with a kernel of size 2:

Output r w

4 1 4

  • 1

2

  • 2

1 3 3 1

Input r w

The average pooling computes average values per block instead of max values.

Fran¸ cois Fleuret Deep learning / 4.5. Pooling 2 / 7

slide-5
SLIDE 5

The most standard type of pooling is the max-pooling, which computes max values over non-overlapping blocks. For instance in 1d with a kernel of size 2:

Output r

4

w

1 4

  • 1

2

  • 2

1 3 3 1

Input r w

The average pooling computes average values per block instead of max values.

Fran¸ cois Fleuret Deep learning / 4.5. Pooling 2 / 7

slide-6
SLIDE 6

The most standard type of pooling is the max-pooling, which computes max values over non-overlapping blocks. For instance in 1d with a kernel of size 2:

Output r

4

w

2 1 4

  • 1

2

  • 2

1 3 3 1

Input r w

The average pooling computes average values per block instead of max values.

Fran¸ cois Fleuret Deep learning / 4.5. Pooling 2 / 7

slide-7
SLIDE 7

The most standard type of pooling is the max-pooling, which computes max values over non-overlapping blocks. For instance in 1d with a kernel of size 2:

Output r

4 2

w

3 1 4

  • 1

2

  • 2

1 3 3 1

Input r w

The average pooling computes average values per block instead of max values.

Fran¸ cois Fleuret Deep learning / 4.5. Pooling 2 / 7

slide-8
SLIDE 8

The most standard type of pooling is the max-pooling, which computes max values over non-overlapping blocks. For instance in 1d with a kernel of size 2:

Output r

4 2 3

w

3 1 4

  • 1

2

  • 2

1 3 3 1

Input r w

The average pooling computes average values per block instead of max values.

Fran¸ cois Fleuret Deep learning / 4.5. Pooling 2 / 7

slide-9
SLIDE 9

The most standard type of pooling is the max-pooling, which computes max values over non-overlapping blocks. For instance in 1d with a kernel of size 2:

Output r

4 2 3 3 1 4

  • 1

2

  • 2

1 3 3 1

Input r w

The average pooling computes average values per block instead of max values.

Fran¸ cois Fleuret Deep learning / 4.5. Pooling 2 / 7

slide-10
SLIDE 10

Input s h r w C

Fran¸ cois Fleuret Deep learning / 4.5. Pooling 3 / 7

slide-11
SLIDE 11

Input Output s h r w C

Fran¸ cois Fleuret Deep learning / 4.5. Pooling 3 / 7

slide-12
SLIDE 12

Input Output s h r w C

Fran¸ cois Fleuret Deep learning / 4.5. Pooling 3 / 7

slide-13
SLIDE 13

Input Output s h r w C

Fran¸ cois Fleuret Deep learning / 4.5. Pooling 3 / 7

slide-14
SLIDE 14

Input Output s h r w C

Fran¸ cois Fleuret Deep learning / 4.5. Pooling 3 / 7

slide-15
SLIDE 15

Input Output s h r w C

Fran¸ cois Fleuret Deep learning / 4.5. Pooling 3 / 7

slide-16
SLIDE 16

Input Output s h r w C

Fran¸ cois Fleuret Deep learning / 4.5. Pooling 3 / 7

slide-17
SLIDE 17

Input Output s h r w C

Fran¸ cois Fleuret Deep learning / 4.5. Pooling 3 / 7

slide-18
SLIDE 18

Input Output s h r w C

Fran¸ cois Fleuret Deep learning / 4.5. Pooling 3 / 7

slide-19
SLIDE 19

Input Output s h r w C

Fran¸ cois Fleuret Deep learning / 4.5. Pooling 3 / 7

slide-20
SLIDE 20

Input Output s h r w C

Fran¸ cois Fleuret Deep learning / 4.5. Pooling 3 / 7

slide-21
SLIDE 21

Input Output s h r w C

Fran¸ cois Fleuret Deep learning / 4.5. Pooling 3 / 7

slide-22
SLIDE 22

Input Output s h r w C

Fran¸ cois Fleuret Deep learning / 4.5. Pooling 3 / 7

slide-23
SLIDE 23

Input Output s h r w C

Fran¸ cois Fleuret Deep learning / 4.5. Pooling 3 / 7

slide-24
SLIDE 24

Input Output s r C s h r w C

Fran¸ cois Fleuret Deep learning / 4.5. Pooling 3 / 7

slide-25
SLIDE 25

Pooling provides invariance to any permutation inside one of the cell. More practically, it provides a pseudo-invariance to deformations that result into local translations.

Fran¸ cois Fleuret Deep learning / 4.5. Pooling 4 / 7

slide-26
SLIDE 26

Pooling provides invariance to any permutation inside one of the cell. More practically, it provides a pseudo-invariance to deformations that result into local translations. Input

Fran¸ cois Fleuret Deep learning / 4.5. Pooling 4 / 7

slide-27
SLIDE 27

Pooling provides invariance to any permutation inside one of the cell. More practically, it provides a pseudo-invariance to deformations that result into local translations. Input

Fran¸ cois Fleuret Deep learning / 4.5. Pooling 4 / 7

slide-28
SLIDE 28

Pooling provides invariance to any permutation inside one of the cell. More practically, it provides a pseudo-invariance to deformations that result into local translations. Input Output

Fran¸ cois Fleuret Deep learning / 4.5. Pooling 4 / 7

slide-29
SLIDE 29

Pooling provides invariance to any permutation inside one of the cell. More practically, it provides a pseudo-invariance to deformations that result into local translations. Input Output

Fran¸ cois Fleuret Deep learning / 4.5. Pooling 4 / 7

slide-30
SLIDE 30

Pooling provides invariance to any permutation inside one of the cell. More practically, it provides a pseudo-invariance to deformations that result into local translations. Input Output

Fran¸ cois Fleuret Deep learning / 4.5. Pooling 4 / 7

slide-31
SLIDE 31

F.max_pool2d(input, kernel_size, stride=None, padding=0, dilation=1, ceil_mode=False, return_indices=False)

takes as input a N × C × H × W tensor, and a kernel size (h, w) or k interpreted as (k, k), applies the max-pooling on each channel of each sample separately, and produce if the padding is 0 a N × C × ⌊H/h⌋ × ⌊W /w⌋ output.

Fran¸ cois Fleuret Deep learning / 4.5. Pooling 5 / 7

slide-32
SLIDE 32

F.max_pool2d(input, kernel_size, stride=None, padding=0, dilation=1, ceil_mode=False, return_indices=False)

takes as input a N × C × H × W tensor, and a kernel size (h, w) or k interpreted as (k, k), applies the max-pooling on each channel of each sample separately, and produce if the padding is 0 a N × C × ⌊H/h⌋ × ⌊W /w⌋ output.

>>> x = torch.empty(1, 2, 2, 6).random_(3) >>> x tensor([[[[1., 2., 1., 1., 0., 2.], [2., 1., 1., 0., 2., 0.]], [[0., 2., 1., 1., 2., 2.], [1., 1., 1., 1., 0., 0.]]]]) >>> F.max_pool2d(x, (1, 2)) tensor([[[[2., 1., 2.], [2., 1., 2.]], [[2., 1., 2.], [1., 1., 0.]]]])

Fran¸ cois Fleuret Deep learning / 4.5. Pooling 5 / 7

slide-33
SLIDE 33

F.max_pool2d(input, kernel_size, stride=None, padding=0, dilation=1, ceil_mode=False, return_indices=False)

takes as input a N × C × H × W tensor, and a kernel size (h, w) or k interpreted as (k, k), applies the max-pooling on each channel of each sample separately, and produce if the padding is 0 a N × C × ⌊H/h⌋ × ⌊W /w⌋ output.

>>> x = torch.empty(1, 2, 2, 6).random_(3) >>> x tensor([[[[1., 2., 1., 1., 0., 2.], [2., 1., 1., 0., 2., 0.]], [[0., 2., 1., 1., 2., 2.], [1., 1., 1., 1., 0., 0.]]]]) >>> F.max_pool2d(x, (1, 2)) tensor([[[[2., 1., 2.], [2., 1., 2.]], [[2., 1., 2.], [1., 1., 0.]]]])

Similar functions implements 1d and 3d max-pooling, and average pooling.

Fran¸ cois Fleuret Deep learning / 4.5. Pooling 5 / 7

slide-34
SLIDE 34

As for convolution, pooling operations can be modulated through their stride and padding. While for convolution the default stride is 1, for pooling it is equal to the kernel size, but this not obligatory. Default padding is zero.

Fran¸ cois Fleuret Deep learning / 4.5. Pooling 6 / 7

slide-35
SLIDE 35

class torch.nn.MaxPool2d(kernel_size, stride=None, padding=0, dilation=1, return_indices=False, ceil_mode=False)

Wraps the max-pooling operation into a Module. As for convolutions, the kernel size is either a pair (h, w) or a single value k interpreted as (k, k).

Fran¸ cois Fleuret Deep learning / 4.5. Pooling 7 / 7

slide-36
SLIDE 36

The end