top of page

CNN vs ANN: Key Differences, Working Principles, and Parameter Comparison Explained

  • Writer: Aryan
    Aryan
  • Jan 19
  • 3 min read

CNN vs ANN

 

Let us understand the difference between ANN and CNN using a simple and intuitive example.

Consider the MNIST dataset, where each image is of size 28 × 28 and represents a handwritten digit, such as the digit 7.

In an Artificial Neural Network (ANN), the image is first flattened into a one-dimensional vector of size 784 (28 × 28). This vector is then passed through one or more hidden layers and finally to the output layer for classification. In this process, the ANN treats each pixel as an independent input and does not explicitly preserve the spatial relationships between pixels.

In a Convolutional Neural Network (CNN), the image is kept in its original 2D form. The network applies filters (kernels) to extract meaningful features from the image. For example, applying a 3 × 3 filter to a 28 × 28 image results in a 26 × 26 feature map (assuming no padding and stride 1). Each filter has its own bias term, which is added to every value in the feature map. The output is then passed through an activation function such as ReLU. After this, pooling is applied to reduce spatial dimensions, followed by flattening, and finally the result is passed to fully connected layers to produce the final prediction.

Although the workflows of ANN and CNN differ, their core learning mechanism is fundamentally similar. In an ANN, each neuron computes a dot product between the input values and weights, adds a bias, and applies an activation function. In a CNN, each filter performs the same operation, but only on a local region of the image. For instance, a 3 × 3 filter takes 9 pixel values, multiplies them with weights, adds a bias, applies an activation function, and generates a single output value. This operation is repeated across the image to form a complete feature map.

So, the core learning principle remains the same:

  • ANN learns neuron weights

  • CNN learns filter weights

The key difference is that ANN operates on the entire input at once, whereas CNN operates on small local regions (windows). Adding a new filter in a CNN is conceptually similar to adding a new neuron in an ANN.

 

Trainable Parameters: CNN vs ANN

 

Consider an RGB image of size 228 × 228 × 3, and suppose we apply 50 filters of size 3 × 3 × 3.

Each filter contains:

  • 3 × 3 × 3 = 27 weights

  • 1 bias

Total trainable parameters:

  • Weights: 27 × 50 = 1,350

  • Biases: 50

  • Total = 1,400 parameters

Even if the input image size increases to 1080 × 1080 × 3, the number of trainable parameters remains 1,400, because it depends only on the filter size and the number of filters, not on the input dimensions.

This is one of the biggest advantages of CNNs. They use fewer parameters, have lower computational cost, and scale efficiently with larger images.

In contrast, in an ANN, increasing the input size directly increases the number of weights and biases in the network. For high-resolution images, this leads to a very large number of parameters, higher computation cost, and a significantly greater risk of overfitting.


Key Differences Between CNN and ANN


  1. Computation cost

    CNNs are computationally efficient due to weight sharing and local connectivity, whereas ANNs become increasingly expensive as the input size grows.

  2. Overfitting

    ANNs are more prone to overfitting because they require a large number of parameters. CNNs mitigate this issue by using fewer, shared parameters.

  3. Spatial feature learning

    CNNs preserve and learn the spatial arrangement of pixels, which is crucial for image data. ANNs lose this spatial structure when the input is flattened.

Because of these reasons, CNNs are generally preferred over ANNs for image-based tasks.

bottom of page