Deep Learning · Beginner Lesson
Neural Networks Explained
Learn what a neural network is using one simple student-result example—before we introduce formulas or code.
You do not need calculus for this lesson.
If you understand “important clues,” “a guess,” and “learning from a mistake,” you already have the ideas needed to begin.
What Is a Neural Network?
A neural network is a computer model that learns a relationship between inputs and an output. It contains small calculation units called neurons, arranged in layers and joined by numbered connections called weights.
During training, the network sees examples with known answers. It makes guesses, checks its mistakes, and slowly changes its weights. After enough useful examples, it can make a prediction for an example it has not seen before.
Important: an artificial neuron is not a real brain cell. It is only a few mathematical operations. The word “neural” comes from historical inspiration, not because the model thinks like a person.
Biological neuron vs artificial neuron
The biological comparison is useful as a memory aid: dendrites receive signals, synapses affect their strength, the cell body combines them, and the axon carries a response. An artificial neuron borrows that rough story using inputs, weights, a calculation, an activation function, and an output.
From one neuron to a complete network
A network connects many artificial neurons in layers. The following diagram shows those parts in our student-result problem.
The Five Key Components of a Neural Network
Before solving an example, first see what a neural network is made of. These five ideas appear in every later section.
Neurons (or nodes)
Small calculation units. A neuron receives numbers, combines them, and sends a new number forward.
Connections
Lines that carry a number from one neuron to another. Each connection has a weight.
Weights and biases
Numbers the network learns. Weights control the strength of connections; a bias gives a neuron an adjustable starting push.
Propagation
The movement of calculations through the network. A forward pass produces an answer; a backward pass carries information about the error.
Learning rule
The method for improving the parameters. Backpropagation finds how each parameter affected the error, and an optimizer changes it a little.
Learning happens in three repeating stages
Input computation
Data enters as numbers. Each neuron multiplies its inputs by weights, adds them, and adds its bias.
Output generation
The values move forward through the layers until the network produces a prediction.
Iterative refinement
The prediction is compared with the known answer. The network adjusts weights and biases, then tries again.
Beginner Word Bank: Know These Terms Before We Use Them
You do not have to memorize this list now. Use it as a map: when a word appears later, you will already know its plain meaning.
Input / feature
A number given to the network, such as study time.
Neuron / node
A unit that multiplies, adds, and activates numbers.
Connection
A path that carries a value from one neuron to another.
Weight (w)
A learned number showing the strength and direction of a connection.
Bias (b)
A learned starting adjustment added inside a neuron.
Weighted sum (z)
Inputs multiplied by weights, added together, then combined with the bias.
Activation function
A rule that changes the weighted sum into the neuron’s outgoing signal.
ReLU
Rectified Linear Unit: it changes negative values to 0 and keeps positive values.
Sigmoid
An activation that turns a number into a value between 0 and 1, often used for a yes/no probability.
Softmax
An output activation that turns several class scores into probabilities adding to 100%.
Layer
A group of neurons working at the same stage: input, hidden, or output.
Prediction / output (ŷ)
The answer produced by the network. The symbol ŷ means “predicted answer.”
Label / target (y)
The known correct answer used during training or evaluation.
Forward pass
Moving calculations from the inputs to the prediction. Also called forward propagation.
Loss
One number that measures how wrong the prediction is. Lower is usually better.
Backpropagation
Calculating how much each parameter contributed to the loss, moving from output toward input.
Optimizer / learning rule
The rule—such as SGD or Adam—that uses gradients to update parameters.
Parameter
Any number the network learns; weights and biases are parameters.
Batch
A small group of training examples processed together.
Epoch
One complete pass through all training examples.
Learning rate
A setting that controls how large each parameter update is.
Notation tip: y is the correct answer; ŷ (“y-hat”) is the network’s predicted answer.
Start With a Real-Life Problem
Our example throughout this lesson
Which students may need extra help before an exam?
A teacher has records from previous students: their study time, attendance, sleep, and whether they passed. The teacher wants a program that can examine a new student’s information and estimate the chance of passing.
Information in
Study, attendance, sleep
Pattern to learn
Which combinations usually lead to passing?
Answer out
A probability such as 67%
We could write fixed rules such as “if study time is above six hours, predict pass.” But real life is rarely one rule. A student may study less and have excellent attendance, or study more but sleep very little. A neural network can learn how several clues work together from examples.
What Happens Inside One Neuron?
A neuron has three small jobs: multiply each input by its weight, add those results and the bias, then activate the result. The diagram follows one imaginary student. To keep the arithmetic readable, we manually scale each teaching input against a stated reference: 8 study hours out of 10 gives 8÷10=0.8; 90% attendance gives 90÷100=0.9; and 7 sleep hours against a 10-hour reference gives 7÷10=0.7. These are teaching choices, not a recommended school-scoring system.
The same calculation, one line at a time
Multiply every clue by its weight
(0.8 × 0.7) + (0.9 × 0.8) + (0.7 × 0.3)
Add the three answers
0.56 + 0.72 + 0.21 = 1.49
Add the bias
1.49 + (−0.80) = 0.69
Apply sigmoid activation
sigmoid(0.69) ≈ 0.67
Read the output
The neuron estimates a 67% chance of passing.
These weights were chosen only to show the arithmetic. In a real network, training discovers useful weight and bias values from data.
Why Do We Need More Than One Neuron?
One neuron can form one simple decision. Many neurons can notice different combinations. One hidden neuron may respond strongly to “high attendance and moderate study,” while another may respond to “long study but little sleep.” The next layer can combine those smaller patterns into a better prediction.
Input layer
Receives values
It does not learn a secret meaning; it holds the facts we provide.
Hidden layer(s)
Builds useful patterns
These layers are called hidden because we do not directly provide or read their answers.
Output layer
Answers the task
Its shape depends on whether we want a number, yes/no answer, or one of many classes.
Why is it called “deep” learning?
A deep neural network contains several learned layers between the input and output. “Deep” describes the stack of transformations—not human-like depth of thought.
How the Network Makes One Prediction
Moving information from input to output is called a forward pass (or forward propagation). Follow our student once through the network:
- 1
Prepare the inputs
Study, attendance, and sleep are converted to numbers on similar scales. Text or images would also need to be converted to numbers.
- 2
Send values into the hidden layer
Every hidden neuron receives the inputs, applies its own weights and bias, and uses an activation function.
- 3
Pass hidden outputs forward
Those outputs become the inputs for the next layer. The same simple neuron calculation happens again.
- 4
Produce a final score
The output neuron returns 0.67. For this teaching task we read that as an estimated 67% chance of passing.
- 5
Apply a decision rule if needed
If this teaching example uses 0.50 as its manually chosen threshold, 0.67 becomes “likely to pass.” The probability and threshold are different things.
How Does a Neural Network Learn?
At the beginning, weights are usually small, unhelpful numbers, so the guesses are poor. Training improves them using examples whose correct answers are known.
Look
Read one training example
Guess
Make a prediction
Check
Measure how wrong it was
Adjust
Change weights a little
The correct answer attached to a training example.
In our example: pass = 1 and fail = 0.
One number that measures how wrong the model is.
In our example: predicting 0.20 when the answer is pass produces more loss than predicting 0.80.
A method for finding how each weight contributed to the loss.
In our example: it sends responsibility for the error backward through the layers.
The rule that uses that information to update the parameters.
In our example: SGD or Adam moves each weight a small amount intended to reduce future loss.
One tiny learning moment
| What happened? | Value | Plain meaning |
|---|---|---|
| Known label | 1 (pass) | This past student actually passed. |
| Network prediction | 0.35 | The model gave only a 35% pass chance. |
| Loss | High | The guess was far from the known answer. |
| Correction | Small weight changes | Backpropagation and the optimizer make the next guess slightly better. |
One pass through all training examples is called an epoch. A small group processed together is a batch. The learning rate controls how large each update is. Too large can jump past a good solution; too small can make learning very slow.
Activation Functions, Without the Mystery
An activation function decides what signal a neuron sends onward. Without non-linear activations, many stacked layers would still behave like one simple straight-line rule.
ReLU
Usually used for: Hidden layers
Negative number → 0. Positive number → keep it.
−2 → 0, 3 → 3
Sigmoid
Usually used for: Yes/no output
Squeezes any number into the range 0 to 1.
0.67 can be read as 67%
Softmax
Usually used for: Many-class output
Turns several scores into probabilities that add to 100%.
cat 70%, dog 20%, bird 10%
Different Neural Networks for Different Data
“Neural network” is a family name. The shape of the network changes to suit the kind of information it receives. As a beginner, remember these main choices:
Dense / Feedforward network
Typical input: Rows of numbers
Data moves forward through fully connected layers.
Example: Student records, house prices, simple classification
Convolutional neural network (CNN)
Typical input: Images and grids
Small filters look for local patterns such as edges and shapes.
Example: Recognizing a cat, reading an X-ray, detecting a road sign
Recurrent network (RNN, LSTM, GRU)
Typical input: Ordered sequences
A state carries information from earlier steps.
Example: Older text systems, speech, and time-series forecasting
Transformer
Typical input: Long sequences and relationships
Attention lets each item consider other relevant items.
Example: Translation, chatbots, summarization, vision models
Autoencoder
Typical input: Compressing and rebuilding data
An encoder compresses; a decoder reconstructs.
Example: Noise removal, anomaly detection, representation learning
Generative adversarial network (GAN)
Typical input: Creating new samples
A generator and a discriminator improve through competition.
Example: Synthetic faces, artwork, data augmentation
There are more specialized architectures, but these six give a beginner the most useful map. Later lessons on this site explain CNNs, recurrent networks, transformers, autoencoders, and GANs separately.
A Complete Two-Layer Forward Pass in NumPy
The single-neuron calculation above explains the basic operation. A layer performs several such calculations together. This executable example uses one student row, two hidden neurons, and one output neuron. Every array is written explicitly so the printed intermediate values can be checked.
X shape [1,3]
1 example × 3 input features
W1 shape [3,2]
3 incoming features × 2 hidden neurons
A1 shape [1,2]
2 hidden outputs for the one example
W2 shape [2,1]
2 hidden outputs × 1 final neuron
import numpy as np
X = np.array([[0.8, 0.9, 0.7]])
W1 = np.array([[ 0.5, -0.4],
[ 0.3, 0.6],
[-0.2, 0.1]])
b1 = np.array([0.1, -0.2])
Z1 = X @ W1 + b1
A1 = np.maximum(0, Z1) # ReLU
W2 = np.array([[0.8],
[0.4]])
b2 = np.array([-0.1])
Z2 = A1 @ W2 + b2
A2 = 1 / (1 + np.exp(-Z2)) # sigmoid
print("Z1:", Z1) # [[0.63 0.09]]
print("A1:", A1) # [[0.63 0.09]]
print("Z2:", Z2) # [[0.44]]
print("A2:", A2) # [[0.60825903]]Try the Neuron in Python
This short program repeats the hand calculation from Figure 4. It does not train a full network yet; it shows exactly how one neuron creates an output.
import math
# One student's input values (scaled between 0 and 1)
study = 0.8
attendance = 0.9
sleep = 0.7
# Example weights and bias
weighted_sum = (
study * 0.7
+ attendance * 0.8
+ sleep * 0.3
- 0.8
)
# Sigmoid changes the raw score into a value from 0 to 1
probability = 1 / (1 + math.exp(-weighted_sum))
print(round(weighted_sum, 2)) # 0.69
print(round(probability, 2)) # 0.67
print(f"Estimated pass chance: {probability:.0%}")
# Estimated pass chance: 67%Now connect neurons with Keras
Libraries create and train all those connected neurons for us. This is the smallest readable model for three student inputs and one yes/no output:
import numpy as np
from tensorflow import keras
keras.utils.set_random_seed(7)
# Eight labelled teaching examples. Each row is
# [study, attendance, sleep]; each target is pass=1 or fail=0.
X_train = np.array([
[0.9, 0.9, 0.8], [0.8, 0.7, 0.7], [0.7, 0.9, 0.6], [0.6, 0.8, 0.8],
[0.2, 0.4, 0.5], [0.3, 0.3, 0.6], [0.4, 0.5, 0.4], [0.1, 0.6, 0.5],
], dtype=np.float32)
y_train = np.array([1, 1, 1, 1, 0, 0, 0, 0], dtype=np.float32)
model = keras.Sequential([
keras.layers.Input(shape=(3,)), # 3 inputs
keras.layers.Dense(4, activation="relu"), # 4 hidden neurons
keras.layers.Dense(1, activation="sigmoid") # pass chance
])
model.compile(
optimizer="adam", # how weights are adjusted
loss="binary_crossentropy", # how wrong each guess is
metrics=["accuracy"]
)
model.fit(X_train, y_train, epochs=50, batch_size=4, verbose=0)
chance = model.predict([[0.8, 0.9, 0.7]])[0][0]
print(f"Estimated pass chance: {chance:.0%}")
# The seed makes this teaching run repeatable on a given setup, but minor
# numerical differences can still occur across TensorFlow versions/hardware.How the calls match the concept
Dense creates trainable weights and biases. compile selects the error rule and update algorithm. fit repeats prediction, loss, gradients and updates. predict performs only the forward calculation with the learned parameter values.
What this example cannot justify
Eight invented rows cannot support a real student decision. A real system would need representative data, clear definitions, separate validation and test sets, fairness review and human oversight. This code exists only to make the mechanics executable.
What Can Go Wrong?
| Problem | In simple English | What to check |
|---|---|---|
| Poor or biased data | The examples do not represent the people or situations where the model will be used. | Coverage, labels, missing groups, and data collection. |
| Overfitting | The network memorizes training examples but performs poorly on new ones. | Validation results, simpler models, regularization, and more useful data. |
| Underfitting | The network has not learned the useful pattern even on training data. | Input quality, model capacity, learning rate, and training time. |
| Wrong metric | A high-looking number hides the failures that actually matter. | Precision, recall, class balance, and real-world cost of mistakes. |
| Too much confidence | A probability is treated as certainty. | Calibration, uncertainty, human review, and safe thresholds. |
Check Your Understanding
1. What does a weight represent?
It represents how strongly one input or neuron influences the next neuron.
2. What are the three basic jobs inside a neuron?
Multiply inputs by weights, add the results and bias, then apply an activation function.
3. What is the difference between a prediction and a label?
A prediction is the network’s guess. A label is the known correct answer supplied in training or evaluation data.
4. Does backpropagation directly choose the final answer?
No. Backpropagation calculates how the parameters contributed to the loss. An optimizer uses that information to adjust them.
5. Which network would you first consider for images?
A convolutional neural network (CNN), because its filters are designed to find local visual patterns.
Summary: The Whole Idea in Seven Lines
- Inputs are numbers that describe one example.
- Weights describe how strongly information should influence the next neuron.
- Each neuron multiplies, adds a bias, and applies an activation function.
- Layers pass those results forward until the network makes a prediction.
- A loss function measures the prediction’s error against the known answer.
- Backpropagation and an optimizer adjust weights and biases.
- Repeating this with useful data lets the network improve on its task.