Weight sharing

Also known as: parameter sharing

On this page 7

Weight sharing is the practice of using one set of learned parameters in several places within a model, so that different positions, time steps, layers or branches apply identical weights. In neural networks, it is the principle behind convolution, recurrence and tied embeddings, and it is one of the most effective ways to build prior knowledge into an architecture.

The technique is also called parameter sharing. Its two main effects are a large reduction in parameter count and an inductive bias that tells the model a pattern means the same thing wherever it appears. Both effects improve generalization when the assumed symmetry matches the data, and both can hurt when it does not.

How weight sharing works during training

Weight sharing works by letting many connections point to the same parameter tensor. In the forward pass, the shared tensor is applied repeatedly, for example a 3×3 kernel slid across every location of an image. In the backward pass, backpropagation computes a gradient for each use, and the gradients are summed into one update for the shared tensor.

This summation is the key mechanism. Each shared weight learns from every location where it is applied, so it receives far more training signal than an unshared weight would. A convolutional layer trained on one image effectively sees thousands of local examples, which explains why convolutional networks learn visual features from moderate datasets.

The parameter savings can be dramatic. The table compares a fully connected layer with a convolutional layer on the same input.

Layer typeOutputWeightsSharing
Fully connected64 unitsAbout 9.6 millionNone
Locally connected 3×364 maps of 222×222About 85 millionNone
Convolutional 3×364 maps of 222×2221,728Across all positions
Parameter count with and without weight sharing on a 224x224x3 input

The locally connected row shows the point clearly: the same local connectivity without sharing needs roughly 50,000 times more weights than convolution, even though both see identical receptive fields.

Forms of weight sharing across architectures

Weight sharing appears in almost every major architecture, each time encoding a different assumption about the data. The table summarizes the main forms and the symmetry each one expresses.

ArchitectureWhat is sharedAssumption encoded
Convolutional networkKernel across spatial positionsTranslation equivariance
Recurrent networkTransition weights across time stepsSame dynamics at every step
TransformerProjection weights across tokensPosition-independent processing
Siamese networkEntire encoder across two inputsInputs mapped to one embedding space
Tied embeddingsInput embedding and output headSame token meaning in and out
Graph neural networkMessage function across edgesPermutation equivariance
Main forms of weight sharing

Sharing can also operate across depth. ALBERT shares all transformer layers, cutting parameters by roughly an order of magnitude, and universal transformers apply one block repeatedly. Cross-layer sharing saves memory but not compute, because each layer pass still costs the same number of operations.

Soft weight sharing is a looser variant. Instead of forcing parameters to be identical, a regularization term pulls them toward each other or toward a small set of shared values. This approach appears in multitask learning and in older compression methods.

Weight sharing is one of several ways to reduce effective model capacity, and it is often confused with techniques that have different goals. The comparison clarifies the boundaries.

TechniqueMechanismMain purpose
Weight sharingSame parameters used in many placesFewer parameters, built-in symmetry
PruningRemoves individual weightsSmaller or faster model after training
QuantizationStores weights at lower precisionLower memory and faster inference
DropoutRandomly disables units in trainingRegularization against co-adaptation
HypernetworkOne network generates another’s weightsFlexible, conditional parameters
Weight sharing and neighboring techniques

Mixture of experts is almost the opposite: it adds many unshared expert blocks and routes each token to a few of them, trading parameter count for capacity. Many modern models combine both, sharing attention weights while keeping expert feedforward blocks separate.

Choosing where to share weights

The right choice depends on whether the data really has the symmetry that sharing assumes. The decision table below summarizes common situations.

SituationRecommended choiceReason
Natural images, audio spectrogramsShare convolution kernelsFeatures recur at any position
Aligned face cropsConsider partial or local sharingEye and mouth positions are fixed
Language model with large vocabularyTie input and output embeddingsSaves tens of millions of weights
Memory-limited deploymentShare layers across depthCuts storage, keeps compute
Very large compute budgetPrefer unshared layersCapacity matters more than size
When weight sharing helps and when it does not

Tied embeddings illustrate the trade-off well. For a vocabulary of 50,000 tokens and a hidden size of 4,096, tying saves about 200 million parameters. Very large models sometimes untie them again because the extra capacity improves quality once memory is less constrained.

Limitations and common misconceptions

  • Fewer parameters is not fewer operations. Shared layers still run their full computation each time they are applied.
  • Convolution is equivariant, not invariant. Shifting the input shifts the feature map; invariance comes later from pooling or global averaging.
  • Padding and striding break perfect symmetry, so convolutional networks can still learn absolute position near image borders.
  • Wrong assumptions reduce accuracy. Sharing forces the model to treat all positions alike, which harms tasks where location carries meaning.
  • Recurrent sharing contributes to vanishing gradients, because the same matrix multiplies the signal at every time step.

The simple explanation

A neural network is made of many numbers that it adjusts while learning. Weight sharing means using the same numbers in many places instead of giving each place its own copy.

Picture a stamp that detects a pattern, such as an edge. You press the same stamp over every part of a photo. You do not need a new stamp for each corner. One tool does the job everywhere, so the network needs far less memory and learns faster from fewer examples.

How it is used in practice

An engineering team builds a defect detector for a factory line that photographs circuit boards at 1,024×1,024 pixels. Scratches and solder bridges can appear anywhere on the board, so the team chooses a convolutional network whose kernels are shared across every position. The first layer needs only a few thousand weights, while a fully connected layer of similar width would need hundreds of millions.

Because each kernel learns from every location in every image, the model reaches reliable accuracy from about 5,000 labeled photos, a dataset the team could collect in a few weeks. The model also fits on an embedded inspection camera. When a later product places a fixed label in one corner, the team adds a small unshared position channel so the network can learn location-specific rules without abandoning shared kernels.