What Is a Neural Network? Definition and Examples
Quick answer
What a neural network is, what hidden layers do, why nonlinearity matters, and a worked forward pass you can run.
A neural network is a machine learning model that stacks simple units called neurons in layers, learning from data how strongly to connect them. Given an input such as pixels or numbers, each layer transforms it, and the final layer produces a prediction such as a digit or a price.
Key takeaways
- A neural network stacks neurons in layers: input, hidden and output.
- It learns weights and biases from data, using a loss function to measure error.
- Without a nonlinear step, stacked layers collapse into a single linear calculation.
- Deep learning refers to networks with many hidden layers.
On this page:
- What a neural network means
- How it works, with a forward pass
- Where neural networks are used
- Common mistakes and confusions
- Related terms
- Frequently asked questions
| Term | Meaning | Relation |
|---|---|---|
| Neural network | Layers of neurons with learned weights | The model itself |
| Neuron (node) | One unit that weighs inputs and adds a bias | A building block |
| Hidden layer | A layer between input and output | Where features are built |
| Deep learning | Training networks with many hidden layers | A subset of the field |
What is a neural network?
IBM (6 October 2021) describes a neural network as a machine learning model that stacks simple neurons in layers, and says its power comes from learning the right weights and biases from data.
The Google Machine Learning Crash Course explains that the additional layers between the input layer and the output layer are called hidden layers, and the nodes in these layers are called neurons.
How does a neural network work?
Each neuron multiplies its inputs by weights, adds a bias, applies a nonlinear step, and passes the result on. Training compares predictions to true labels with a loss function, then uses backpropagation and gradient descent to adjust the parameters, as IBM describes.
A forward pass with made-up numbers: inputs (2, 3), one hidden neuron with weights (0.5, -0.2) and bias 0.1, a ReLU activation, then an output weight of 1.5. The hidden value is 0.5*2 + (-0.2)*3 + 0.1 = 0.5. ReLU keeps positive values, so it stays 0.5. The output is 0.5 * 1.5 = 0.75.
import numpy as np
x = np.array([2.0, 3.0])
w_hidden = np.array([0.5, -0.2])
b_hidden = 0.1
w_out = 1.5
hidden = max(0.0, float(w_hidden @ x + b_hidden)) # ReLU
output = hidden * w_out
print(round(hidden, 2), round(output, 2)) # 0.5 0.75Why the nonlinear step matters: Google says linear calculations performed on the output of linear calculations are also linear, so a model without nonlinearity cannot learn nonlinearities. In maths, two linear layers W2 and W1 give W2(W1x), which equals (W2W1)x, one linear map.
Where are neural networks used?
They are used for images, speech, text and forecasting. An illustrative Indian example: reading a handwritten PIN code digit from a postal form. A 28 by 28 pixel image goes in, hidden layers build up strokes and shapes, and the output layer picks a digit from 0 to 9. No accuracy figures are claimed.
See how this fits with the wider field in AI vs machine learning vs deep learning and machine learning vs deep learning.
What are the common mistakes?
- Thinking it copies the brain. The name is a loose analogy; it is a set of learned numbers.
- Skipping the nonlinearity. Without it, depth adds nothing.
- Confusing network and deep learning. Deep learning means many hidden layers.
Which terms are related?
Transformers, loss functions and gradient descent build on this idea. Read what a transformer model is, types of machine learning and maths for machine learning.
Next step
Change the weights in the snippet and watch the output move. Then add a second hidden neuron and repeat.
Frequently asked questions
What is a neural network in simple words?
It is a machine learning model that stacks simple neurons in layers and learns, from data, the weights and biases that turn an input into a useful prediction.
What are hidden layers?
Hidden layers are the additional layers between the input layer and the output layer, and their nodes are called neurons.
Why do neural networks need activation functions?
Linear calculations on linear outputs are still linear, so a model without nonlinearity cannot learn nonlinear patterns. An activation function adds that nonlinear step.
How does a neural network learn?
It compares predictions to true labels with a loss function, then uses backpropagation and gradient descent to adjust weights and biases.
What is the difference between a neural network and deep learning?
A neural network is the model. Deep learning is the practice of using networks with many hidden layers.