Modules / Deep Learning / Network Architecture

What is Parameter Sharing?

Visualize why Convolutional Neural Networks are so efficient. See how a single set of shared weights is reused across the entire image, drastically reducing the number of parameters compared to a Dense layer.

The Shared Parameters

These 4 parameters are shared and applied everywhere.

Total CNN Weights Used: 4
Dense Equivalent: 144

Current Calculation

Click "Slide Filter" to view shared operations.

Understanding Parameter Sharing

Why Convolutional layers are drastically more efficient than Fully Connected layers.

What is Parameter Sharing?

In a traditional Fully Connected (Dense) neural network layer, every output node is connected to every input node with a unique weight (parameter). If you process an image, a specific pixel in the top-left corner has a completely different weight than a pixel in the bottom-right corner.

Parameter Sharing (or Weight Sharing) is the core innovation of Convolutional Neural Networks (CNNs). Instead of learning a separate weight for every pixel, the network learns a small set of weights (a filter/kernel) and shares that exact same set of weights across the entire image by sliding it around.

The Massive Efficiency Gain

Let's look at the math for the simple interactive above. We have a 4x4 input grid (16 pixels) and we are generating a 3x3 output grid (9 pixels).

  • Without Parameter Sharing (Dense Layer): Every one of the 9 output pixels needs a connection to all 16 input pixels.
    16 inputs × 9 outputs = 144 unique parameters (weights).
  • With Parameter Sharing (CNN): We use a 2x2 filter. The filter only has 4 weights. We simply slide those same 4 weights to 9 different locations.
    Total parameters = 4 unique parameters (weights).

For a real-world 1080p image, a Dense layer would require trillions of parameters. A CNN might only require a few hundred. Parameter sharing makes image processing computationally possible.

Guided Experiments with This Interactive

  1. Watch the Colors:

    Click the Slide Filter button. Watch the formula in the center column. The 4 weights are color-coded (Red, Blue, Yellow, Purple). Notice that as the green highlight box slides across different areas of the Input Image, the exact same colored weights are used over and over again to do the multiplication.

  2. Translation Invariance:

    Because the weights are shared, the filter is looking for the exact same pattern everywhere. If the weights represent a "vertical edge detector", it will find a vertical edge whether it's in the top-left of the image or the bottom-right. This property is called Translation Invariance—a cat is recognized as a cat regardless of where it is in the photo.

  3. Change the Shared Rules:

    Change the weights in the center kernel box to something extreme (like 10, 0, 0, 0). Click slide again. You'll see that changing the parameters once immediately alters how the network interprets the entire image, because the rule applies globally.

Are All Parameters Shared?

In a CNN, weights are shared spatially (across the width and height of the image), but they are not shared across different filters (channels).

A single Convolutional layer usually has many filters (e.g., 32 filters). Filter #1 (looking for edges) has its own 9 shared weights. Filter #2 (looking for colors) has a different set of 9 shared weights.

Key Takeaways

  • Parameter sharing reuses the same weights across different spatial locations.
  • It drastically reduces memory and computation requirements.
  • It forces the network to learn global patterns (Translation Invariance).
  • It prevents severe overfitting by heavily restricting the number of variables the model can memorize.
Cheat sheet

Parameter Sharing in CNN

Visualize why Convolutional Neural Networks are so efficient. See how a single set of shared weights is reused across the entire image, drastically reducing the number of parameters compared to a Dense layer.

COMPUTER VISION · vizlearn.in/computer_vision/parameter_sharing_in_cnn.html