[Python] How to specify padding with keras in Conv2D layer?

Discussão em 'Python' iniciado por Stack, Dezembro 1, 2024.

  1. Stack

    Stack Membro Participativo

    I am trying to implement AlexNet with Keras and was inspecting the network design in MATLAB which is given as follows

    [​IMG]

    As could be seen, the second convolution layer has 256 filters of size 5x5, 48 channels and a padding of [ 2 2 2 2 ]. How could I specify padding of [ 2 2 2 2] with Keras? I went through the documentation of Conv2D. It accepts only 2 values for padding namely valid and same. I could not understand this. For what I know, valid would mean zero padding. How could I specify [2 2 2 2] padding with the second convolution layer? I created the first layer as:

    model.add(keras.layers.Conv2D(filters = 96, kernel_size = (11,11),
    strides = (4,4), padding = "valid", input_shape=(227,227,3)))


    Also, since in the second layer there are 48 channels, do I need to be explicit about it?

    Continue reading...

Compartilhe esta Página