CNN

Convolutional Neural Networks (CNNs), are neural network architectures inspired by the human visual system, designed to process image data by capturing spatial relationships between pixels.

  • Learn hierarchical features from simple edges to complex objects
  • Capture spatial patterns using convolution operations
  • Detect objects regardless of their position in the image
  • Reduce computation by focusing on local regions instead of the entire image

Key Components of CNN

A complete Convolution Neural Networks architecture is also known as covnets. A covnets is a sequence of layers and every layer transforms one volume to another through a differentiable function. Let’s take an example by running a covnets on of image of dimension 32 x 32 x 3. 

1. Input Layer

The input layer receives the raw image data and passes it to the network for processing. In CNNs, input is typically a 3D volume (width × height × depth).

  • Stores pixel values of the image (e.g., 32 × 32 × 3 for RGB images).
  • Preserves the spatial structure of the image for further feature extraction.

2. Convolutional Layer

The Convolutional Layer is responsible for extracting important features from the input data. It applies a set of learnable filters (kernels) that slide over the image and compute the dot product between the filter weights and corresponding image patches, producing feature maps.

  • Uses small filters (e.g., 2×2, 3×3, 5×5) to scan the input image.
  • Generates feature maps that capture patterns such as edges, textures and shapes.

Example: Using 12 filters results in an output volume of 32 × 32 × 12.

3. Activation Layer

The Activation Layer introduces non-linearity into the network by applying an element-wise activation function to the output of the convolution layer. This enables the model to learn complex patterns beyond linear relationships.

  • Common activation functions include ReLU, Tanh and Leaky ReLU.
  • Applied element-wise to the feature maps.
  • The output dimensions remain unchanged (e.g., 32 × 32 × 12).

4. Pooling Layer

The Pooling Layer is used to reduce the spatial dimensions of the feature maps, making computation faster, reducing memory usage and helping to prevent overfitting. It is typically inserted between convolutional layers in a CNN.

  • Common types include Max Pooling and Average Pooling.
  • Reduces width and height while keeping depth unchanged.

Example: Using 2 × 2 max pooling with stride 2 reduces the volume from 32 × 32 × 12 to 16 × 16 × 12.

5. Flattening

Flattening converts the multi-dimensional feature maps into a one-dimensional vector after convolution and pooling. This vector is then passed to the fully connected layer for classification or regression.

Example: Flattening 16 × 16 × 12 results in a vector of size 3072 (16 × 16 × 12).

6. Fully Connected Layer

The fully connected (dense) layer performs high-level reasoning using extracted features and produces the final classification scores.

Example: The 3072-length vector is connected to neurons for classification

7. Output Layer

The output layer converts final scores into probabilities using activation functions like Sigmoid (binary classification) or Softmax (multi-class classification).To be uploaded shortly.