Think of a network as connected calculations
Suppose you want software to estimate whether a photo contains a handwritten digit. The program cannot rely on one fixed pixel rule because the same digit can be written in many shapes. A neural network learns numerical transformations that combine pieces of input information into a prediction.
At the smallest level, an artificial neuron takes numbers, multiplies each by a weight, adds a bias, and usually passes the result through an activation function. A layer is a group of such units. Connecting layers allows the network to build more complicated patterns than a single linear calculation can represent.
For a concrete example, imagine two input measurements: the height and width of a handwritten mark. A neuron might give height a positive weight, width a negative weight, and use the bias to shift its decision boundary. During training, the weights and bias are adjusted based on examples. Real image networks use many more inputs and richer arrangements of layers, but the basic operation is recognizable.
Importantly, an artificial neuron is a mathematical component, not a tiny digital brain. The next sections introduce the exact notation, explain why nonlinear activation matters, and show how these pieces become an entire model.
An artificial neural network (ANN) is a computational model made of connected processing units that transform inputs into outputs using adjustable numerical parameters. Many neural networks learn these parameters from data so that they can classify inputs, predict numerical values, or generate representations useful for other tasks.
Neural networks are a major family of models in machine learning. Deep learning generally refers to machine learning with networks containing multiple layers of learned transformations. Despite the name, artificial neurons are simplified mathematical operations, not faithful simulations of biological brain cells.
This article focuses on the components and computations that make a neural network work. The next articles examine how information and gradients propagate through networks and how networks are trained.
1. The fundamental idea
Consider a model that predicts whether a transaction is likely to be fraudulent. Inputs might include the transaction amount, account activity, and distance from the usual purchase location. A neural network takes numerical representations of those inputs, combines them with learned parameters, and produces an output such as a score or estimated probability.
The essential distinction from a hand-written rule system is that the network’s numerical parameters can be estimated from examples instead of specifying every decision boundary manually.
A network defines a parameterized function:
where:
- is an input vector.
- is the network’s computation.
- denotes its learnable parameters, typically weights and biases.
- is the network’s output or prediction.
The architecture determines which computations are possible. Training determines the particular parameter values used by those computations.
2. What is an artificial neuron?
A basic artificial neuron computes a weighted sum of its inputs, adds a bias, and applies an activation function:
Here, is input , is its weight, is the bias, is the pre-activation value, is the activation function, and is the neuron’s output.
Worked calculation
Suppose a neuron has two inputs:
Its weighted sum is:
If the neuron uses the ReLU activation, , its output is:
A different input, set of weights, or activation function could produce a different output. One neuron performs a small computation; many connected neurons can represent more complex relationships.
3. Weights: how inputs influence computations
A weight is a learnable parameter that scales an input or intermediate value. The magnitude and sign of a weight affect the weighted sum, but its interpretation depends on the other inputs, the network architecture, and the activation functions.
For a fixed input representation:
- A positive weight increases the weighted sum as its associated input increases.
- A negative weight decreases the weighted sum as its associated input increases.
- A zero weight contributes nothing from that connection to the sum.
A weight does not by itself reveal the real-world importance or causal effect of a feature. Other weights and nonlinear transformations can change the final result.
In a dense neural-network layer, the weights are collected into a matrix. This lets the layer compute many neurons efficiently using linear algebra.
4. Biases: adjustable offsets
A bias is an additional learnable value added to a weighted sum. It lets a neuron shift its response independently of its inputs.
Consider a neuron without an activation function:
If , the resulting line must pass through the origin. If , the line can have a nonzero intercept. In a neuron with an activation function, changing the bias can shift when or how strongly the neuron activates.
Not every neural-network component uses a bias, but biases are common in dense and convolutional layers.
5. Layers and network architecture
A layer groups computations that operate on an input representation. In a basic feedforward multilayer perceptron (MLP), information moves through an ordered series of layers.
Input representation
The network receives an input vector, such as four measured attributes of a flower or a sequence of numeric features describing a transaction. The term input layer usually refers to this entry representation; it is not necessarily a layer with trainable parameters.
Hidden layers
Hidden layers transform incoming values into intermediate representations. A dense hidden layer computes weighted combinations of all inputs, then usually applies a nonlinear activation function.
Output layer
The output layer maps the final intermediate representation to values suitable for the task. For example:
| Task | Typical output | Common final activation |
|---|---|---|
| Predict a numerical target | One or more real-valued predictions | Linear (no additional nonlinearity) |
| Binary classification | One score or probability | Sigmoid for a probability |
| Multiclass classification | One score per class | Softmax for class probabilities |
| Multilabel classification | One score or probability per label | Sigmoid for each label |
An implementation may output raw logits rather than explicit probabilities because certain loss functions combine the activation and loss calculation for numerical stability.
Architecture illustration
Depth and width
Depth usually describes the number of successive learned transformations, while width describes how many units are in a layer. Conventions for counting the input and output layers vary, so specify the architecture rather than relying only on a layer count.
A network with more layers is not automatically better. Appropriate size depends on the task, available data, compute budget, and risk of overfitting.
6. Activation functions and nonlinearity
An activation function transforms a neuron’s pre-activation value. Nonlinear activations are essential for ordinary multilayer perceptrons to represent nonlinear functions.
Without nonlinear activations, composing dense layers yields another affine transformation. For example, two layers with linear computations become:
That expression has the same general form as a single affine layer. Nonlinearity enables networks to construct richer decision boundaries and representations.
| Activation | Definition or behavior | Common use |
|---|---|---|
| ReLU | Hidden layers in many networks | |
| Sigmoid | , mapping to | Binary-probability outputs and gating |
| Tanh | Maps values to | Some recurrent networks and hidden units |
| Softmax | Converts a vector of scores to positive values summing to 1 | Mutually exclusive class probabilities |
| GELU | Smoothly scales inputs according to their values | Many Transformer feed-forward blocks |
Softmax operates on a vector, rather than acting as a separate scalar transformation on each output independently:
An activation should be chosen with the task, training procedure, and loss function in mind.
7. Matrix form of a dense layer
For a column-vector input and a dense layer containing neurons:
where:
- is the weight matrix.
- is the bias vector.
- are the layer’s pre-activations and activations.
For several layers, the output of one becomes the input to the next:
Here identifies the layer and is the original input. Matrix shapes must agree at every step.
How many parameters?
A dense layer with inputs and neurons has:
learnable parameters when each neuron has a bias.
For example, a dense layer with four inputs and three neurons has parameters. If a second dense layer maps those three outputs to one output, it adds , for 19 total parameters.
The parameter count matters for memory and computation, but it does not alone determine model quality or explainability.
8. Build a tiny network with NumPy
The following example performs a forward pass through a two-layer network. The weights are chosen manually for demonstration. Because no training occurs, the output is not a learned prediction.
import numpy as np
# One sample with three numerical input features.
x = np.array([1.0, 2.0, -1.0])
# Hidden layer: 3 inputs -> 2 neurons.
W1 = np.array([
[0.2, -0.1, 0.5],
[0.7, 0.3, -0.4],
])
b1 = np.array([0.1, -0.2])
# Output layer: 2 hidden values -> 1 output score.
W2 = np.array([[0.6, -0.3]])
b2 = np.array([0.05])
def relu(values):
return np.maximum(0.0, values)
def sigmoid(values):
return 1.0 / (1.0 + np.exp(-values))
hidden_pre_activation = W1 @ x + b1
hidden = relu(hidden_pre_activation)
output_score = W2 @ hidden + b2
output_probability = sigmoid(output_score)
print("Hidden pre-activations:", hidden_pre_activation)
print("Hidden activations:", hidden)
print("Output probability:", output_probability.item())
Expected output, rounded:
Hidden pre-activations: [-0.3 1.5]
Hidden activations: [0. 1.5]
Output probability: 0.401312339887548
The sigmoid converts the final score into a number between zero and one. Interpreting that number as a meaningful probability requires an appropriate task, training procedure, and evaluation; a sigmoid alone does not make a network calibrated or accurate.
What changes during training?
During training, an optimizer updates the weights and biases based on a loss computed from training examples. The network’s structure and computations remain defined by its architecture, although some training methods can also change or select the architecture.
The distinction is useful:
- Forward pass: compute outputs from the current parameters.
- Loss: measure mismatch between outputs and learning targets.
- Backpropagation: calculate how the loss changes with parameters.
- Optimizer step: use gradients to update parameters.
See Forward Propagation and Backpropagation for the computational details.
9. Why neural networks are useful
Neural networks can learn representations suited to different tasks. Depending on their architecture and training data, they are used in:
- Classification: identifying image categories or classifying text.
- Regression: predicting continuous quantities, such as energy usage.
- Computer vision: processing image and video inputs.
- Natural language processing: modeling and generating language.
- Speech and audio: recognizing speech or generating sound.
- Representation learning: producing embeddings used in retrieval and other downstream systems.
Different architectures impose different structural assumptions. A basic dense network is useful for understanding the core mathematics, but a convolutional network, recurrent network, or Transformer uses additional operations suited to particular information structures.
10. Limitations and common misunderstandings
More neurons do not guarantee better performance
Larger networks can fit more complex functions, but they may need more training data, computation, regularization, and careful evaluation. Architecture choice is a trade-off rather than a competition to maximize parameter count.
Weights are not a simple explanation of decisions
Individual weights usually cannot be interpreted as direct feature-importance scores. Predictions depend on combinations of weights, activations, interactions, and input representations.
Output scores are not automatically reliable probabilities
A classifier may be overconfident, poorly calibrated, or wrong on inputs unlike its training data. Evaluation and calibration are separate concerns from producing a numerical score.
Networks can memorize training-specific patterns
If a model fits the training data but performs poorly on new samples, it may be overfitting. Validation data, suitable regularization, representative datasets, and robust evaluation help detect and address this problem.
Neural networks are not the only machine-learning approach
Linear models, decision trees, ensembles, and other methods can outperform a neural network for a particular dataset or engineering constraint. The best choice depends on the task, not the popularity of the model family.
11. Check your understanding
- What are the roles of a weight, a bias, and an activation function in a neuron?
- Why can several dense layers with only linear activations be replaced by one affine transformation?
- What are the shapes of and for a layer with five inputs and eight neurons?
- How many learnable parameters are in that layer if every neuron has a bias?
- What is the difference between computing a forward pass and training a network?
Show worked answers
- A weight scales a corresponding input; a bias adds an offset; an activation transforms the weighted sum, often nonlinearly.
- The composition of affine transformations remains affine, so it does not introduce new nonlinear behavior.
- and .
- parameters.
- A forward pass computes outputs using current parameters. Training also measures loss and adjusts learnable parameters using an optimization procedure.
12. Related PlainCS articles
Prerequisites
- Vectors and Matrices
- Vector and Matrix Operations
- Optimization and Gradient Descent
- Model Training, Overfitting, and Generalization
Continue learning
- Forward Propagation and Backpropagation
- Training Neural Networks: Loss, Optimizers, and Regularization
- Convolutional and Recurrent Neural Networks
- Deep Learning with PyTorch
- AI Knowledge Map
The follow-on articles are part of the planned knowledge map; their links become active as those pages are published.
13. References and further reading
- Goodfellow, Bengio, and Courville, Deep Learning, Chapter 6: Deep Feedforward Networks.
- Google Machine Learning Crash Course: Neural Networks.
- PyTorch Tutorials, for practical tensor computations and neural-network implementations.
- scikit-learn: Neural Network Models, for multilayer perceptrons in supervised learning.
Related articles in
- Convolutional and Recurrent Neural Networks — Understand convolutional networks for spatial data and recurrent networks for sequences, including CNN filters, RNN state, LSTMs, GRUs, and practical PyTorch examples.
- Deep Learning with PyTorch — Build, train, evaluate, and save a neural network with PyTorch using tensors, automatic differentiation, datasets, and optimization loops.
- Forward Propagation and Backpropagation — Learn how neural networks compute predictions with forward propagation and calculate parameter gradients with backpropagation, using the chain rule and a worked example.