Convolution Layer

Convolutional Layers are deep learning layers that are commonly used on images. But their purpose is to extract features from spatial data.

The convolution layer uses filters of certain width and height, these filters convolve on the whole image. In Convolution Layers, weights are in the form of 1D, 2D, or 3D matrix. This weight matrix is multiple with the images.

Convolution Layer Parameters

Filters: Convolution layers can have many filters which are specified by filters parameter in Keras. Filters have sizes as width and height. filter size is called the kernel.

The number of pixels that filter moves is called Stride, stride will have different values of each dimension, such as in 2D there will be different values for row and column. in 3D there will be 3rd value for depth.


Keras

In Keras, we have 1D Conv, 2D Conv, and 3D Conv.

Conv1D

1D Conv layer is used with 1 Dimensional spatial data such as text, or DNA sequences.
its filters are 1 Dimensional means only 1 row and many columns

Code
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
tf.keras.layers.Conv1D(
    filters,
    kernel_size,
    strides=1,
    padding="valid",
    data_format="channels_last",
    dilation_rate=1,
    groups=1,
    activation=None,
    use_bias=True,
    kernel_initializer="glorot_uniform",
    bias_initializer="zeros",
    kernel_regularizer=None,
    bias_regularizer=None,
    activity_regularizer=None,
    kernel_constraint=None,
    bias_constraint=None,
    **kwargs
)

Conv2D

2D Conv is used with 2 Dimensional Spatial data such as images.
its filters are 2 Dimensional means rows and many columns

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
tf.keras.layers.Conv2D(
    filters,
    kernel_size,
    strides=(1, 1),
    padding="valid",
    data_format=None,
    dilation_rate=(1, 1),
    groups=1,
    activation=None,
    use_bias=True,
    kernel_initializer="glorot_uniform",
    bias_initializer="zeros",
    kernel_regularizer=None,
    bias_regularizer=None,
    activity_regularizer=None,
    kernel_constraint=None,
    bias_constraint=None,
    **kwargs
)

Conv3D

its filters are 3 Dimensional which are rows, columns, and depth as well.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
tf.keras.layers.Conv3D(
    filters,
    kernel_size,
    strides=(1, 1, 1),
    padding="valid",
    data_format=None,
    dilation_rate=(1, 1, 1),
    groups=1,
    activation=None,
    use_bias=True,
    kernel_initializer="glorot_uniform",
    bias_initializer="zeros",
    kernel_regularizer=None,
    bias_regularizer=None,
    activity_regularizer=None,
    kernel_constraint=None,
    bias_constraint=None,
    **kwargs
)

No comments:

Post a Comment

Building a CLI-Based People Tracking and Dwell Time Analytics System Using YOLOv8 and DeepSORT

  Introduction Tracking people across video frames and analyzing their behavior (like  dwell time ) is a crucial task for many real-world ap...