3.1.2 · D1Neural Network Fundamentals

Foundations — Multi-layer perceptron architecture

2,680 words12 min readBack to topic

Before you can read a single formula in the parent note, you must own the tools it silently assumes. We build them in the exact order the machine uses them: a number → a list of numbers → a weighted sum → a bias shift → a bending curve → a whole layer at once → a probability.


1. A single number, and what a "neuron" holds

A neuron (also called a node) is nothing mystical. It is a little box that will eventually hold one number. That number is called its activation.

Why do we need this idea at all? Because a network's "thought" at any moment is just the collection of brightnesses across all its boxes. Learning = adjusting the machine so those brightnesses light up sensibly.

Figure — Multi-layer perceptron architecture

Look at the figure: three boxes glowing at different brightnesses. Each glow is one activation number. That is the entire content of a "neuron holding a value."


2. A list of numbers — the vector

The parent note writes the input as . Let us dismantle that notation piece by piece — nothing here is allowed to be mysterious.

  • The bold ::: means "this is a whole list, treat it as one object."
  • The subscript ::: means "the single number sitting in slot ."
  • The T superscript () ::: means transpose — flip a horizontal row into a vertical column. We stack numbers vertically because that is how the weighted-sum machinery (Section 5) lines them up.
Figure — Multi-layer perceptron architecture

Why does the topic need vectors? Because an input (10 tumor measurements, 784 pixels) is naturally many numbers at once. Bundling them into one bold lets us talk about "the input" as a single thing.


3. The weighted sum — earning , , and

Here is the heart of the machine. A neuron does not treat all its inputs equally — it weights them.

Now the sum. The symbol (capital Greek "sigma") is just shorthand for "add up a bunch of terms":

Why this exact tool and not plain addition? Plain addition treats every input as equally important — the machine could never learn that "radius matters a lot, texture barely at all." Multiplying each input by its own tunable weight before adding is what makes the neuron adjustable. Training is nothing but nudging these values.

Figure — Multi-layer perceptron architecture

4. The bias — a shift knob

The parent note adds a to every weighted sum. Why?

Putting Sections 3 and 4 together gives the parent's pre-activation:

The letter is just the name we give to "the number right before we bend it." The parent writes it as — read the superscript as "which layer" and the subscript as "which neuron in that layer." They are address labels, nothing more.

  • decoded ::: the pre-activation number of neuron living in layer .
  • decoded ::: the weight feeding into neuron (layer ) from neuron of the previous layer.

5. Bending the result — the activation function

So far is a linear thing: doubling inputs doubles . Stacking linear steps gives you… still just one linear step (the parent proves ). To get real power we must bend the number. That bender is .

The three curves the parent uses, in plain words and pictures:

  • ReLU, ::: "keep positives, flatten negatives to 0" — a hinge/ramp.
  • Sigmoid, ::: a smooth S that squeezes any number into the range .
  • Tanh, ::: an S centred at 0, squeezing into .
Figure — Multi-layer perceptron architecture

Here is Euler's number , and means "raise to the power ." Why exponentials? Because shrinks toward 0 for big and blows up for very negative — exactly the tug-of-war that produces the smooth S-shape and, later, the probability-maker in the output layer. No simpler function bends smoothly between two flat ends the way does.

You now own the full single-neuron pipeline: .


6. Doing a whole layer at once — matrices

A layer has many neurons, each with its own weighted sum. Writing for every neuron is exhausting, so we pack all the weights into one grid called a matrix.

How multiplication works — it is just dot products. The operation means: take each row of and dot-product it with the column (the dot product you earned in Section 3 — multiply matching slots, add them up). Each row produces one number, so a matrix hitting a column yields numbers stacked into a column. That is why "row times column" is precise: row-times-column = dot product.

Now the whole layer collapses into two lines:

Every bold letter here is a vector from Section 2: is the incoming activations-vector, is the biases-vector, is the pre-activations stacked up, and applied to a vector means "bend every entry, one at a time."

Why the matrix form at all? It is the same maths as Sections 3–5 — a pile of dot products — but written as a single symbol. Beyond neat notation, computers have hardware (and libraries like NumPy and PyTorch) built to crunch matrix multiplications extremely efficiently, so running all neurons in one matrix step is typically far faster in practice than writing an explicit loop over neurons in plain Python. (The exact speed-up depends on your hardware and problem size — the point is simply "one bulk operation beats many tiny ones.")

Recall

Shape check for a -neuron layer fed by inputs. Size of ::: (rows = new neurons, columns = incoming numbers). Size of ::: (a column of the 10 inputs). Size of the result ::: (one pre-activation per new neuron).


7. Turning scores into probabilities — softmax and

The output layer for many classes needs numbers that behave like probabilities: all positive, all adding to 1. The tool that does this is called softmax, and the parent writes it as:

Read it slowly with the tools you now have:

  • ::: how many classes (e.g. 10 for digits).
  • ::: exponentiate score guarantees a positive number (Section 5).
  • ::: add up the exponentials of all scores — the grand total (Section 3's ).
  • dividing ::: turns each positive number into a share of the whole, so the shares add to exactly 1.

That is why exponentiation appears: it is the cheapest smooth way to force positivity and amplify the biggest score into the biggest probability.


Prerequisite map

The diagram below shows how each foundation you just built feeds into the next, ending at the parent topic. Read it bottom-up: a single number becomes a list, a list plus weights becomes a dot-product sum, the sum plus bias becomes , bent by becomes an activation, many neurons pack into a matrix, and the output stage uses for softmax — all converging on the MLP.

single number = activation a

ordered list = vector x

weight w

dot product = weighted sum

add bias b gives z

bend with curve sigma gives a

stack many neurons = matrix W

exponential e for softmax

MLP layer

3.1.2 MLP Architecture

Each arrow is a "you need the tail before you can use the head" dependency: for example, you cannot understand the matrix step (G) until you own the dot product (D), which itself needs both a vector (B) and a weight (C).



Equipment checklist

Self-test — cover the right side and answer before revealing.

  • What does the bold signal, versus plain ? ::: Bold = the whole ordered list (vector); = the single number in slot 1.
  • What is a weights-vector , a biases-vector , an activations-vector ? ::: Bold columns holding, respectively, all of a neuron's weights, one bias per neuron in a layer, and every neuron's activation in a layer.
  • What does capital compute? ::: , a single weighted-sum total.
  • What is the dot product ? ::: Multiply matching slots and add them all up — exactly the weighted sum .
  • Why multiply inputs by weights before adding? ::: So the neuron can learn which inputs matter; plain addition treats all inputs equally and can't be tuned.
  • What does the bias let a neuron do? ::: Fire (or refuse) independent of the inputs — it shifts the decision boundary off the origin.
  • What is the pre-activation ? ::: The weighted sum plus bias, before the curve is applied: .
  • Why apply a non-linear ? ::: Without bending, stacking layers collapses to one linear map ; breaks that so depth adds real power.
  • Lowercase vs capital ? ::: bends one number with a curve; adds many numbers up.
  • What does "row times column" in actually mean? ::: A dot product of that matrix row with the input column — one number per row.
  • What is and why does softmax use it? ::: Euler's number ; is always positive and smoothly amplifies larger scores, so shares can sum to 1.
  • What do the superscript and subscript in mean? ::: = which layer; = which neuron inside that layer — address labels only.
  • What is the shape of for a layer of neurons fed by inputs? ::: (rows = new neurons, columns = incoming numbers).