Tweaking your convolutions

Keras ile Görüntü Modellemesi

Ariel Rokem

Senior Data Scientist, University of Washington

Convolution

Keras ile Görüntü Modellemesi

Convolution with zero padding

Keras ile Görüntü Modellemesi

Zero padding in Keras

model.add(Conv2D(10, kernel_size=3, activation='relu', 
                 input_shape=(img_rows, img_cols, 1)),
                 padding='valid')
Keras ile Görüntü Modellemesi

Zero padding in Keras

model.add(Conv2D(10, kernel_size=3, activation='relu', 
                 input_shape=(img_rows, img_cols, 1)),
                 padding='same')
Keras ile Görüntü Modellemesi

Strides

Keras ile Görüntü Modellemesi

Strides in Keras

model.add(Conv2D(10, kernel_size=3, activation='relu', 
                 input_shape=(img_rows, img_cols, 1)),
          strides=1)
Keras ile Görüntü Modellemesi

Strides in Keras

model.add(Conv2D(10, kernel_size=3, activation='relu', 
                 input_shape=(img_rows, img_cols, 1)),
          strides=2)
Keras ile Görüntü Modellemesi

Example

Keras ile Görüntü Modellemesi

Calculating the size of the output

$$O = ((I - K + 2P) / S) + 1$$

where

  • $I$ = size of the input
  • $K$ = size of the kernel
  • $P$ = size of the zero padding
  • $S$ = strides
Keras ile Görüntü Modellemesi

Calculating the size of the output

$$ 28 = ((28 - 3 + 2) / 1) + 1$$

$$ 10 = ((28 - 3 + 2) / 3) + 1$$

Keras ile Görüntü Modellemesi

Dilated convolutions

Keras ile Görüntü Modellemesi

Dilation in Keras

model.add(Conv2D(10, kernel_size=3, activation='relu', 
                 input_shape=(img_rows, img_cols, 1)),
          dilation_rate=2)
Keras ile Görüntü Modellemesi

Let's practice!

Keras ile Görüntü Modellemesi

Preparing Video For Download...