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?
Conv2D class. 2D convolution layer (e.g. spatial convolution over images). This layer creates a convolution kernel that is convolved with the layer input to produce a tensor of outputs. If use_bias is True, a bias vector is created and added to the outputs.
Keras Layers are the functional building blocks of Keras Models. Each layer is created using numerous layer_() functions. These layers are fed with input information, they process this information, do some computation and hence produce the output. Further, this output of one layer is fed to another layer as its input.
The Upsampling layer is a simple layer with no weights that will double the dimensions of input and can be used in a generative model when followed by a traditional convolutional layer.
Keras Conv2D is a 2D Convolution Layer, this layer creates a convolution kernel that is wind with layers input which helps produce a tensor of outputs.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With