简体   繁体   中英

Output convolutional layer using keras python

I need help in understanding CNN.

model = keras.models.Sequential()

model.add(convolutional.Convolution2D(32, (8,8), activation='relu', strides=(4, 4), padding='same',input_shape=(80,80,4)))

model.add(convolutional.Convolution2D(64, (4, 4), activation='relu', strides=(2, 2), padding='same'))

model.add(convolutional.Convolution2D(64, (3, 3), activation='relu', strides=(1, 1), padding='same'))

I'm not sure about the output of the first CNN. I know that it goes over 32 filters, the kernel size is 8x8 and strides 4x4. I also know about this formula on calculating the width:

W=(W−F+2P)/S+1

W = (80 - 8 + ?? ) / 4 + 1

I'm not sure what to put on P - which means padding . Can you help me understand the size of the output of the first CNN ? Also, can you help me understand why the filters are changed from 32 to 64 after the first step? Is there any good reason for that?

The parameter padding=same means that your input will be padded so that the output of this layer has the same length as the original input. Adding padding to the input just means adding pixels (commonly of value 0) around the outside edges of the input. You want to do this so that the specified filters are able to convolve the entire input without missing some of the pixel values on the edges. More details on the use of this parameter in a Keras conv layer can be found in the Keras docs here .

To see the output size of these layers, run model.summary() . This will show you the output size of each layer in your model.

Lastly, the filter size is chosen/set arbitrarily, but generally speaking, filters usually increase in size in later layers as the model becomes deeper and more complex. I have a video on CNNs that explain these concepts and show the process visually, which you may find useful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM