← Back to blog

What is a Neuron?

A gentle intro to neurons, weights, biases, and ReLU while I learn the basics of neural networks.

Mar 12, 2026

When people talk about neurons in machine learning, they usually mean a tiny mathematical unit that takes some numbers in and produces a single number out.

At its core, a neuron does three things:

  1. Takes inputs – a vector of numbers, e.g. features from your data.
  2. Applies weights and a bias – it computes a weighted sum of those inputs.
  3. Passes the result through an activation function – often something like ReLU.

Weights and bias

Suppose your inputs are x1,x2,…,xnx_1, x_2, \dots, x_n.
Your neuron has the same number of weights w1,w2,…,wnw_1, w_2, \dots, w_n and one bias bb.

It first computes:

z=w1x1+w2x2+β‹―+wnxn+bz = w_1 x_1 + w_2 x_2 + \dots + w_n x_n + b

What does this mean?

  • x1,x2,…,xnx_1, x_2, \dots, x_n are your inputs (the data you feed in, like pixel values or features).
  • w1,w2,…,wnw_1, w_2, \dots, w_n are the weights (how much each input matters).
  • bb is the bias (a constant that shifts everything).
  • zz is the result (a single number).

A simple example: If you have 3 inputs with values x1=2x_1 = 2, x2=3x_2 = 3, x3=1x_3 = 1, and weights w1=0.5w_1 = 0.5, w2=0.3w_2 = 0.3, w3=0.8w_3 = 0.8, and bias b=1b = 1, then:

z=(0.5Γ—2)+(0.3Γ—3)+(0.8Γ—1)+1=1+0.9+0.8+1=3.7z = (0.5 \times 2) + (0.3 \times 3) + (0.8 \times 1) + 1 = 1 + 0.9 + 0.8 + 1 = 3.7
  • Weights tell the neuron how important each input is. A larger weight means that input has more influence.
  • The bias shifts the whole function left or right, letting the neuron fire even when all inputs are small or zero.

You can think of zz as the raw score before the neuron decides how strongly to respond.

ReLU and other activations

If we only used the weighted sum zz, a whole network of neurons would just behave like one big linear function. That’s why we add a non-linear activation function.

One of the most popular is ReLU (Rectified Linear Unit):

ReLU(z)=max⁑(0,z)\text{ReLU}(z) = \max(0, z)

What does this mean?

max⁑(0,z)\max(0, z) means β€œtake the larger of 0 and zz”. In other words:

  • If zz is positive (like z=5z = 5), ReLU outputs that same number: ReLU(5)=5\text{ReLU}(5) = 5.
  • If zz is negative (like z=βˆ’3z = -3), ReLU outputs 0: ReLU(βˆ’3)=0\text{ReLU}(-3) = 0.

Examples:

  • ReLU(7)=7\text{ReLU}(7) = 7 (positive stays positive)
  • ReLU(βˆ’2)=0\text{ReLU}(-2) = 0 (negative becomes zero)
  • ReLU(0)=0\text{ReLU}(0) = 0 (zero stays zero)

This simple shape makes networks easier to train and gives them the ability to model complex, non-linear relationships in data. It’s like a β€œrectifier” that cuts off anything below zero.

Other activation functions

ReLU is just one choice. A few other common activations:

  • Sigmoid – squashes values into (0,1)(0, 1), historically used in early neural nets and for probabilities:

    Οƒ(z)=11+eβˆ’z\sigma(z) = \frac{1}{1 + e^{-z}}

    What does this mean?

    • ee is Euler’s number (approximately 2.718), a mathematical constant.
    • eβˆ’ze^{-z} means β€œe raised to the power of negative z”.
    • The formula takes any number zz (positive or negative) and squashes it into a value between 0 and 1.

    Examples:

    • If z=0z = 0, then Οƒ(0)=11+e0=11+1=0.5\sigma(0) = \frac{1}{1 + e^0} = \frac{1}{1 + 1} = 0.5 (middle value).
    • If zz is very large (like z=10z = 10), Οƒ(10)β‰ˆ1\sigma(10) \approx 1 (approaches 1).
    • If zz is very negative (like z=βˆ’10z = -10), Οƒ(βˆ’10)β‰ˆ0\sigma(-10) \approx 0 (approaches 0).

    Think of it as a smooth S-curve that converts any number into a probability-like value between 0 and 1.

  • Tanh – similar to sigmoid but outputs in (βˆ’1,1)(-1, 1) and is zero-centered:

    tanh⁑(z)=ezβˆ’eβˆ’zez+eβˆ’z\tanh(z) = \frac{e^{z} - e^{-z}}{e^{z} + e^{-z}}

    What does this mean?

    • Like sigmoid, this uses ee (Euler’s number).
    • eze^z is β€œe raised to the power of z”, and eβˆ’ze^{-z} is β€œe raised to the power of negative z”.
    • The formula divides the difference by the sum, which creates an S-curve like sigmoid, but centered at zero.

    Examples:

    • If z=0z = 0, then tanh⁑(0)=0\tanh(0) = 0 (exactly zero, unlike sigmoid which gives 0.5).
    • If zz is large positive (like z=5z = 5), tanh⁑(5)β‰ˆ1\tanh(5) \approx 1 (approaches 1).
    • If zz is large negative (like z=βˆ’5z = -5), tanh⁑(βˆ’5)β‰ˆβˆ’1\tanh(-5) \approx -1 (approaches -1).

    The key difference from sigmoid: tanh outputs can be negative, and it’s centered at zero, which can help with training.

  • Leaky ReLU – like ReLU but allows a small negative slope so neurons don’t die completely:

    LeakyReLU(z)={zifΒ zβ‰₯0Ξ±zifΒ z<0\text{LeakyReLU}(z) = \begin{cases} z & \text{if } z \ge 0 \\ \alpha z & \text{if } z < 0 \end{cases}

    What does this mean?

    This is a piecewise function (it behaves differently depending on the value of zz):

    • If zβ‰₯0z \ge 0 (zero or positive): output is just zz, same as regular ReLU.
    • If z<0z < 0 (negative): output is Ξ±Γ—z\alpha \times z, where Ξ±\alpha is a small number like 0.010.01.

    Examples:

    • If z=5z = 5, then LeakyReLU(5)=5\text{LeakyReLU}(5) = 5 (positive stays positive).
    • If z=βˆ’3z = -3, then LeakyReLU(βˆ’3)=0.01Γ—(βˆ’3)=βˆ’0.03\text{LeakyReLU}(-3) = 0.01 \times (-3) = -0.03 (small negative value, not zero).

    The Ξ±\alpha parameter (often 0.010.01) is the β€œleak” – it lets a tiny bit of negative signal through instead of completely cutting it off. This prevents neurons from β€œdying” (always outputting zero) during training.

Interactive Activation Functions

ReLU
0.0000
Sigmoid
0.5000
Tanh
0.0000
Leaky ReLU
0.0000

ReLU

Rectified Linear Unit

f(0.0) = 0.0000

Sigmoid

S-shaped curve, outputs (0, 1)

f(0.0) = 0.5000

Tanh

Hyperbolic tangent, outputs (-1, 1)

f(0.0) = 0.0000

Leaky ReLU

ReLU with small negative slope

f(0.0) = 0.0000
Current input: 0.0 | Try adjusting the slider or input field to see how different values affect each activation function. The red dashed lines show the current input and output values.

Putting it together

A single neuron computes:

output=Ο•(w1x1+β‹―+wnxn+b)\text{output} = \phi(w_1 x_1 + \dots + w_n x_n + b)

What does this mean?

This is the complete formula for a neuron:

  1. First part (w1x1+β‹―+wnxn+bw_1 x_1 + \dots + w_n x_n + b): Compute the weighted sum of inputs plus bias. This gives you zz (the raw score).
  2. Second part (Ο•(… )\phi(\dots)): Apply the activation function to zz. The Greek letter Ο•\phi (phi) is just a placeholder for whatever activation function you choose.

In plain English: Multiply each input by its weight, add them all up, add the bias, then pass that result through an activation function.

Example with ReLU:

  • Inputs: x1=2x_1 = 2, x2=3x_2 = 3
  • Weights: w1=0.5w_1 = 0.5, w2=0.3w_2 = 0.3
  • Bias: b=1b = 1
  • First compute: z=(0.5Γ—2)+(0.3Γ—3)+1=2.9z = (0.5 \times 2) + (0.3 \times 3) + 1 = 2.9
  • Then apply ReLU: output=ReLU(2.9)=2.9\text{output} = \text{ReLU}(2.9) = 2.9

where Ο•\phi can be ReLU, sigmoid, tanh, or something more modern like GELU or SiLU.

Comparing activation functions

When you stack many neurons into layers, and many layers into a network, you get the neural networks used in modern deep learning. But underneath, it’s all built from this same pattern: inputs β†’ weighted sum + bias β†’ activation.

This post is my starting point while I’m learning more about how these pieces connect to training, loss functions, and backpropagation.