I want to write own convolution layer same as Convolution2D. How it works in Keras? For example, if Convolution2D(64, 3, 3, activation='relu', input_shape=(3,226,226) Which equation will be for output data?
How exactly Convolution2D layer works in Keras?
Asked Answered
Keras is built on top of Tensorflow and Theano. What do you mean by "to write own convolution"? Do you want to implement a convolutional layer with means of Tensorflow/Theano or from scratch? –
Irreligion
I want to write own cnn lib, but for test use pre-trainded Keras or Tensorflow model. I want to figure out how these libs use input data and weights in convolution layer to get output data. –
Lipid
Since you input image shape is (266, 266, 3)[tf]/(3, 266, 266)[th], and the filter number is 64, and the kernel size is 3x3, and for padding, I think the default padding is 1, and the default stride is 1.
So, the output is 266x266x64.
output_width=output_height=(width – filter + 2*padding)/stride + 1
in your code, the width=266, the filter=3, the padding=1, and stride=1.
If you have any trouble understanding the basic concepts, I think you can read this cs231n post for more information.
For how to understanding the process of conv, click here.
Actually, Keras is not doing a convolution in conv2d. In order to speed up the process, the convolution operation is converted into a matrix (row-per-column) multiplication. More info here, at chapter 6.
© 2022 - 2024 — McMap. All rights reserved.