MulaiMulai sekarang secara gratis

Add padding to a CNN

Padding allows a convolutional layer to retain the resolution of the input into this layer. This is done by adding zeros around the edges of the input image, so that the convolution kernel can overlap with the pixels on the edge of the image.

Latihan ini adalah bagian dari kursus

Image Modeling with Keras

Lihat Kursus

Petunjuk latihan

Add a Conv2D layer and choose a padding such that the output has the same size as the input.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Initialize the model
model = Sequential()

# Add the convolutional layer
model.add(____(10, kernel_size=3, activation='relu', 
                 input_shape=(img_rows, img_cols, 1), 
                 ____))

# Feed into output layer
model.add(Flatten())
model.add(Dense(3, activation='softmax'))
Edit dan Jalankan Kode