Home / Neural Networks

Weights & Biases

Discover how Artificial Intelligence evaluates information and makes decisions using its core adjustable parameters.

Configuration

Architecture

Network Idle

Analysis

Overview

Discover how Artificial Intelligence evaluates information and makes decisions using its core adjustable parameters.

In this guide
  1. What each one does geometrically
  2. A concrete case
  3. Why the bias cannot be dropped
  4. Counting a layer's params
  5. What training really changes
  6. One concrete case
  7. What they are, and how many there are
  8. Reading trained weights, and the limits of doing so
  9. Try this above
  10. What often goes wrong
  11. In one line
  12. Where the bias is left out on purpose
  13. Their role in training
  14. Count the params, then see what each one does
  15. Questions people ask
  16. Recap in one screen

Weights & Biases: A Practical Guide

Weights and biases are the numbers a network actually learns. Every other setting you choose is in service of finding good values for these two.

What each one does geometrically

A neuron computes z = w · x + b. Those two terms do other jobs, and it is worth separating them:

  • Weights rotate. They set the orientation of the decision edge — which way in input space the neuron is sensitive to. And how strongly.
  • The bias translates. It slides the edge without turning it. Without a bias each edge is forced through the origin. It is a severe and often pointless restriction.

Together they set a linear function. In a single neuron with n inputs, the weights are n counts and the bias is one count, giving n + 1 learnable params. A fully connected layer with 784 inputs and 256 outputs has 784 × 256 weights plus 256 biases, totalling 200,960 params. A deep network stacks many such layers. And the total param count — tens of millions for a modest net, billions for a large one — is almost fully weights and biases.

Training adjusts these counts. The forward pass computes predictions with the current weights and biases. The loss function measures how wrong the predictions are. Backpropagation computes the gradient of the loss with respect to each weight and each bias. The optimiser (SGD, Adam) nudges each param in the way that reduces the loss. This cycle repeats for each batch of training data. And over thousands of iterations the weights and biases converge toward vals that make the network's output match the training labels.

Initialisation matters since the starting vals of weights find whether gradients flow or vanish. Setting all weights to zero makes each neuron identical. So the network cannot learn other features — this is the symmetry-breaking problem. The standard fix is random initialisation scaled to the layer width: Xavier initialisation for tanh/sigmoid activations, He initialisation for ReLU. Biases are often initialised to zero. It is fine since the weights now break symmetry.

A concrete case

One input, weight w = 2.0, bias b = 0. At x = 0.5 you get z = 1.0 — the neuron fires.

Now set b = −1.5 and leave all else alone: z = 1.0 − 1.5 = −0.5. Same input, same weight, opposite decision. The bias moved the threshold from x > 0 to x > 0.75.

This is why a bias is not optional detail. It is the gap between "is this input positive?" and "is this input above the level that really matters?"

Why the bias cannot be dropped

Without a bias, the weighted sum is zero whenever each input is zero. So the decision edge is forced through the origin. That is a severe restriction: a neuron that should fire just when its input exceeds 5 cannot express that threshold at all, since it has no way to shift its output independently of the inputs.

The bias supplies just that freedom. In y = wx + b, w tilts the line and b slides it — and the same is true in a thousand dimensions. There the weights orient a hyperplane and the bias offsets it from the origin. One extra param per neuron buys the ability to place the edge anywhere rather than just through a single fixed point.

Counting a layer's params

A fully connected layer with nin inputs and nout outputs has one weight per connection plus one bias per output neuron:

params = (nin × nout) + nout

For 784 inputs and 128 outputs that is 784 × 128 + 128 = 100,480. The biases are 128 of them — about 0.1% of the total. It is why they are cheap enough to always include and why regularisation often skips them.

Notice the weight count is a product. Doubling either the input or the output size doubles the params. Doubling both quadruples them. That quadratic growth is why wide layers dominate a network’s memory footprint.

What training really changes

Training changes nothing about the network except these counts. The design, the activations and the connections are all fixed before the first step. Gradient descent just ever adjusts weights and biases.

That is worth holding onto, since it clarifies what a trained net is: a set set of vals for these params. Saving a net saves the weights and biases. Transfer learning reuses another net’s weights and biases. A randomly initialised network and a fully trained one differ in no other respect.

One concrete case

One input, weight w = 2.0, bias b = 0. At x = 0.5 you get z = 1.0 — the neuron fires.

Now set b = −1.5 and change nothing else: z = 1.0 − 1.5 = −0.5. Same input, same weight, opposite decision.

The bias moved the threshold. Before, the neuron fired whenever x > 0. Now it fires whenever x > 0.75. That is the gap between asking "is this input positive?" and "is this input above the level that really matters?"

Which is why a bias is not an optional detail. A network without biases can just draw edges through the origin. And almost no real decision edge passes through the origin.

What they are, and how many there are

Weights are the multipliers on the connections between units. A layer taking 100 inputs into 50 units has a 100×50 weight matrix — 5,000 counts, one for each input-output pair.

Biases are one count per unit — 50 in that layer — added after the weighted sum.

z = w · x + b

Both are learned. All else you set — the count of layers, the learning rate, the batch size — is in service of finding good vals for these two.

A useful proportion: biases are a tiny fraction of a network's params. A layer with 100 inputs and 50 units has 5,000 weights and 50 biases. So about 1%. They are cheap and they matter.

Reading trained weights, and the limits of doing so

In a single-layer net, a weight's magnitude is interpretable: a large positive coefficient on "smoking" means smoking pushes the prediction up. That reading is why logistic regression survives in regulated settings.

In anything deeper, it breaks down. A feature's influence is spread across many paths. And a small first-layer weight can still matter enormously downstream through amplification in later layers. Reading a single weight as feature weight in a deep network is unreliable. And integrated gradients or SHAP are the tools that do the job well.

Two things that are worth reading from trained weights:

Wildly other magnitudes across features is almost always a symptom of unscaled inputs, not a finding. If one feature is measured in thousands and another in decimals, the network compensates with tiny and huge weights. And gradient descent struggles to move both usefully. Scale the inputs instead.

The distribution of weight magnitudes tells you whether regularisation is doing anything. A histogram concentrated near zero with a few large vals is what weight decay gives.

Try this above

  1. Set Count of Inputs to 1 so there is a single weight to watch.
  2. Change that weight and watch the response curve steepen and flip way. Negative weights invert the neuron's opinion of that feature.
  3. Now change just the bias. The shape stays identical; it slides sideways.
  4. Switch Activation Function between Step and Sigmoid and repeat — the geometry is the same, just the sharpness changes.

What often goes wrong

Wildly other weight magnitudes are almost always a symptom of unscaled inputs rather than a real finding. If one feature is measured in thousands and another in decimals, the network compensates with tiny and huge weights. And gradient descent struggles to move both usefully. Scale the inputs instead.Reading a single weight as feature weight is unreliable in anything deeper than one layer. In a multi-layer network a feature's influence is spread across many paths. And a small first-layer weight can still matter enormously downstream.

In one line

Weights decide way and strength. The bias decides where the threshold sits.

Where the bias is left out on purpose

There are two standard cases where a bias is omitted.

Before batch normalisation. Normalisation subtracts the mean, which cancels any constant the last layer added. So a convolution followed by batch normalisation has a redundant bias. And reference implementations write bias=False. It saves params and changes nothing.

In some attention projections, where recent language nets drop biases from the query/key/value projections and sometimes from the feed-forward layers as well — they turn out to add little at scale. And removing them simplifies the net slightly.

Otherwise, keep the bias. The default in each framework includes it for good reason.

Their role in training

At initialisation, weights are small random vals and biases are zero. Random weights break the symmetry between units — identical weights would mean identical gradients and units that never differentiate. Biases can start at zero since the weights now differ.

In training, both are updated by the same rule:

w ← w − η ∂L/∂w    b ← b − η ∂L/∂b

The gradient with respect to a weight includes the input value (∂z/∂w = x). So a feature that is always near zero gives near-zero gradients and its weight barely moves. The gradient with respect to a bias is just the upstream gradient (∂z/∂b = 1). So biases update no matter the input scale — another reason they train reliably.

One deliberate exception to zero-initialised biases: setting the final bias of a binary classifier to the log-odds of the positive class makes the net start out predicting the base rate. It noticeably speeds up early training on imbalanced data.

Count the params, then see what each one does

A layer is a matrix and a vector. This counts them for a real design, then moves single vals to watch what they control.

example_01.pyNumPy
Output

Now see what a single weight and bias each control when you nudge them.

example_02.pyNumPy
Output

Questions people ask

How many params does a layer have? inputs × units weights plus units biases.

Why initialise weights randomly but biases to zero? Random weights break symmetry between units. Once they differ, zero biases cause no problem.

Can weights be negative? Yes, and roughly half will be. A negative weight means the feature counts against that unit's activation.

Should biases be regularised? No. Weight decay is often applied to weights just — biases carry no capacity worth penalising.

What does a weight of zero mean? That the connection is effectively unused. L1 regularisation gives just zero weights. L2 gives small but non-zero ones.

Do biases increase capacity? Not in the sense of expressiveness across features. But they let each edge sit where the data needs rather than through the origin — which is a large real gap.

Recap in one screen

  • Weights are the learned multipliers on connections. Biases are one learned offset per unit.
  • Weights set the edge's way and strength. The bias sets where the threshold sits.
  • Without a bias, each edge passes through the origin.
  • Individual weights are interpretable in a one-layer net and unreliable in a deep one.
  • Very uneven weight magnitudes often mean unscaled inputs, not an insight.
  • Drop the bias when batch normalisation follows. And exclude biases from weight decay.

Recall check

0 of 3

Say the answer out loud before you reveal it — recalling it is what makes it stick, and rereading it is not.

  1. Without scrolling back — what is the one-line takeaway from this module?

  2. What does this module say about “What each one does geometrically”?

  3. What does this module say about “A concrete case”?

Cheat sheet

Weights & Biases

See what the numbers a network learns are actually for: weights scale each input, bias shifts where the neuron fires.

DEEP LEARNING · vizlearn.in/deep_learning/weights_and_biases.html

About the author

Ashish Jangra builds and maintains VizLearn. Every module here is written and the visualisation behind it hand-built, so the numbers in a readout come from the same code that draws the picture. Corrections are genuinely welcome and get priority over everything else — if a page states something wrong, or an animation misrepresents what the algorithm does, get in touch.