Tweaking your convolutions

Pemodelan Citra dengan Keras

Ariel Rokem

Senior Data Scientist, University of Washington

Convolution

Pemodelan Citra dengan Keras

Convolution with zero padding

Pemodelan Citra dengan Keras

Zero padding in Keras

model.add(Conv2D(10, kernel_size=3, activation='relu', 
                 input_shape=(img_rows, img_cols, 1)),
                 padding='valid')
Pemodelan Citra dengan Keras

Zero padding in Keras

model.add(Conv2D(10, kernel_size=3, activation='relu', 
                 input_shape=(img_rows, img_cols, 1)),
                 padding='same')
Pemodelan Citra dengan Keras

Strides

Pemodelan Citra dengan Keras

Strides in Keras

model.add(Conv2D(10, kernel_size=3, activation='relu', 
                 input_shape=(img_rows, img_cols, 1)),
          strides=1)
Pemodelan Citra dengan Keras

Strides in Keras

model.add(Conv2D(10, kernel_size=3, activation='relu', 
                 input_shape=(img_rows, img_cols, 1)),
          strides=2)
Pemodelan Citra dengan Keras

Example

Pemodelan Citra dengan Keras

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
Pemodelan Citra dengan Keras

Calculating the size of the output

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

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

Pemodelan Citra dengan Keras

Dilated convolutions

Pemodelan Citra dengan Keras

Dilation in Keras

model.add(Conv2D(10, kernel_size=3, activation='relu', 
                 input_shape=(img_rows, img_cols, 1)),
          dilation_rate=2)
Pemodelan Citra dengan Keras

Let's practice!

Pemodelan Citra dengan Keras

Preparing Video For Download...