Tutorial: Neural Networks Unit I – Biological Neuron, Artificial Neuron & Activation Functions
Introduction to Neural Networks
Neural networks are computational models inspired by the structure and functioning of biological brains. They form the foundation of modern artificial intelligence and deep learning.
A neural network consists of interconnected computational units called artificial neurons. These neurons receive inputs, process them using weights, biases, and activation functions, and produce outputs.
Before studying advanced topics such as multi-layer perceptrons, loss functions, gradient descent, and backpropagation, it is important to understand three fundamental concepts:
- Biological neurons
- Artificial neurons
- Activation functions
This tutorial introduces these concepts step by step.
1. Biological Neuron
A biological neuron is the fundamental functional unit of the nervous system. Neurons receive information, process it, and transmit signals to other neurons.
A simplified biological neuron consists of several important components.
Main Components
1. Dendrites
Dendrites are branch-like structures that receive signals from other neurons or sensory receptors.
They act as the primary input structures of a neuron.
2. Cell Body (Soma)
The cell body, also called the soma, contains the nucleus and other cellular components.
It integrates the signals received through the dendrites and determines whether the neuron should generate an electrical signal.
3. Axon
The axon is a long structure that carries the electrical signal away from the cell body.
The signal can travel over a relatively long distance along the axon.
4. Synapse
A synapse is the junction through which one neuron communicates with another neuron.
Chemical neurotransmitters are commonly released from the end of one neuron's axon and interact with receptors on another neuron.
Simplified Information Flow
The overall process can be represented as:
In a simplified view, a neuron receives multiple signals, integrates them, and produces an output signal when its activation reaches a certain threshold.
This basic idea inspired the mathematical model of an artificial neuron.
2. From Biological Neuron to Artificial Neuron
Artificial neural networks are inspired by the basic information-processing behavior of biological neurons.
A biological neuron receives signals from other neurons. Similarly, an artificial neuron receives numerical inputs.
The biological and artificial concepts can be approximately related as follows:
| Biological Neuron | Artificial Neuron |
|---|---|
| Dendrites | Inputs |
| Synaptic strength | Weights |
| Cell body | Weighted-sum computation |
| Firing threshold | Bias / threshold |
| Neural activation | Activation function |
| Axon output | Neuron output |
This is only a simplified analogy. Artificial neurons do not reproduce the complete biological behavior of real neurons.
3. Artificial Neuron
An artificial neuron is a mathematical model that receives multiple inputs and combines them using weights and a bias.
Suppose a neuron receives inputs:
Each input has an associated weight:
The neuron first calculates a weighted sum.
Here:
| Symbol | Meaning |
|---|---|
| Input value | |
| Weight associated with input |
The weighted sum is then passed through an activation function.
Therefore, the complete artificial neuron can be written as:
4. Understanding Weights
A weight determines how strongly an input influences the neuron.
Consider a neuron with two inputs:
If is large and positive, then has a strong positive influence on the output.
If is negative, increasing tends to decrease the value of .
For example:
means that the corresponding input contributes twice its value to the weighted sum.
Similarly:
means that the second input contributes negatively to the weighted sum.
Weights are usually learned automatically during neural-network training.
5. Understanding Bias
The bias allows a neuron to shift its activation or decision boundary.
For a simple neuron:
Without a bias:
the decision boundary is constrained to pass through the origin.
Adding a bias provides additional flexibility:
For a threshold-based neuron, the decision boundary occurs when:
Therefore:
and the corresponding boundary is:
Thus, the bias controls the position of the decision boundary.
6. Weighted Sum
The weighted sum is one of the most important operations in a neural network.
For three inputs:
For inputs:
The value is often called the pre-activation because it is calculated before applying the activation function.
The activation function then transforms this value:
7. Vector Representation
The same neuron can be represented more compactly using vectors.
Let the input vector be:
and the weight vector be:
The weighted sum can then be written as:
The neuron output becomes:
This vector notation is commonly used when implementing neural networks with libraries such as NumPy, PyTorch, and TensorFlow.
8. Perceptron
The perceptron is one of the earliest and simplest models of an artificial neuron.
A perceptron computes a weighted sum and applies a threshold function.
The mathematical form is:
The output is:
The perceptron can learn the parameters and from training data.
A single perceptron can solve linearly separable classification problems.
Examples include the logical AND and OR functions.
However, a single perceptron cannot solve problems that are not linearly separable, such as XOR.
9. Activation Functions
An activation function transforms the weighted sum of a neuron.
Without an activation function, a neural network containing multiple linear layers would still represent only a linear transformation.
For example, consider two linear transformations:
This can be rearranged as:
which is still a linear or affine transformation.
Therefore, activation functions introduce non-linearity, allowing neural networks to learn complex relationships.
The general neuron equation is:
Common activation functions include:
- Step function
- Sigmoid
- ReLU
- Tanh
- Leaky ReLU
- Softmax
10. Step Function
The step function, also called the threshold function, produces a binary output.
It can be defined as:
The output is either or .
Example
Suppose:
Since:
the output is:
For:
we have:
therefore:
Advantages
- Simple to understand
- Produces a binary decision
- Historically important in perceptron models
Limitation
The step function is not differentiable at the threshold and has a derivative of zero almost everywhere.
Therefore, it is unsuitable for modern gradient-based backpropagation.
11. Sigmoid Function
The sigmoid function produces a smooth output between and .
It is defined as:
Therefore:
for finite values of .
Example
For:
we get:
For a large positive value of :
the sigmoid approaches:
For a large negative value:
the sigmoid approaches:
Derivative
The derivative of the sigmoid has a particularly useful form:
Advantages
- Smooth and differentiable
- Output lies between and
- Useful for binary classification output layers
Disadvantages
- Can suffer from vanishing gradients
- Not zero-centered
- Computationally more expensive than ReLU
12. ReLU
ReLU stands for Rectified Linear Unit.
It is one of the most commonly used activation functions in deep neural networks.
The ReLU function is:
It can also be written as:
Example
For:
we get:
For:
we get:
Derivative
For values away from zero, the derivative can be expressed as:
ReLU is not differentiable exactly at . In practical implementations, a subgradient convention is used.
Advantages
- Simple and computationally efficient
- Helps reduce vanishing-gradient problems compared with sigmoid and tanh
- Commonly used in hidden layers
Disadvantage
A neuron can become inactive if it consistently receives negative inputs. This is commonly called the dying ReLU problem.
13. Leaky ReLU
Leaky ReLU is a modification of ReLU that allows a small negative output.
It is defined as:
where is a small positive constant, such as:
For example:
Unlike standard ReLU, the negative region has a small non-zero slope.
This can help reduce the dying ReLU problem.
14. Tanh Function
The hyperbolic tangent, or tanh, is another commonly used activation function.
It is defined as:
Its exponential form is:
The output range is:
Important values
At zero:
For large positive values:
For large negative values:
Derivative
The derivative is:
Advantages
- Zero-centered output
- Smooth and differentiable
- Often preferable to sigmoid when a zero-centered hidden representation is useful
Disadvantage
Like sigmoid, tanh can suffer from vanishing gradients for large positive or negative values.
15. Softmax Function
The softmax function is commonly used to convert a vector of logits into a probability distribution for multi-class classification.
For classes, the softmax function is:
for:
The resulting probabilities satisfy:
and:
For example, if a model produces three logits:
softmax converts them into three values that sum to .
Softmax is commonly used in the output layer of a multi-class classifier.
16. Activation Function Comparison
| Activation | Output Range | Main Use | Main Limitation |
|---|---|---|---|
| Step | Basic perceptron | Not suitable for gradient-based learning | |
| Sigmoid | Binary classification output | Vanishing gradients | |
| Tanh |
17. Choosing an Activation Function
The appropriate activation function depends on the part of the neural network.
Hidden Layers
For many modern neural networks, ReLU and its variants are common choices:
Other architectures may use functions such as GELU, SiLU/Swish, or other specialized activations.
Binary Classification
For a binary classification problem, a sigmoid output is commonly used:
The output can be interpreted as a probability for the positive class when used in the standard binary-classification setup.
Multi-Class Classification
For a multi-class classification problem, softmax is commonly used:
The class with the highest probability can be selected as the predicted class:
18. Example: Single Artificial Neuron
Consider a neuron with two inputs:
and weights:
Let the bias be:
The weighted sum is:
Substituting the values:
Therefore:
and:
Using ReLU:
Therefore:
The neuron produces an output of .
19. Example: Perceptron for AND Gate
The AND operation produces only when both inputs are .
| AND | ||
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
Consider the perceptron:
Using the step function:
For:
we obtain:
Since:
the output is:
For:
we obtain:
Since:
the output is:
Thus, this perceptron correctly implements the AND operation.
20. Linear Separability
A single perceptron can solve problems that are linearly separable.
For two-dimensional inputs, the decision boundary can be represented by:
This equation represents a straight line.
The perceptron divides the input space into two regions:
and:
One region produces output , while the other produces output .
Problems such as AND and OR are linearly separable.
The XOR problem is not linearly separable, so a single perceptron cannot solve it.
21. Why Multiple Layers Are Needed
A single neuron has limited expressive power.
A neural network can combine many neurons into layers.
A simple feed-forward neural network consists of:
Each neuron in a layer performs a transformation such as:
The activation function is then applied:
where represents the layer number.
For example, a two-layer neural network can be written as:
Then:
and finally:
This layered structure allows neural networks to learn increasingly complex representations.
22. Key Concepts to Remember
Biological Neuron
A biological neuron receives, processes, and transmits signals.
Artificial Neuron
An artificial neuron calculates a weighted sum:
and applies an activation function:
Therefore:
Activation Function
Activation functions introduce non-linearity:
Without non-linear activation functions, stacking linear layers cannot provide the expressive power needed for learning complex non-linear relationships.
23. Quick Revision
Remember these important formulas:
Artificial Neuron
Neuron Output
Step Function
Sigmoid
Sigmoid Derivative
ReLU
Tanh
Tanh Derivative
Leaky ReLU
Softmax
24. Summary
In this unit, we studied the fundamental concepts behind neural networks.
A biological neuron receives and processes signals through structures such as dendrites, the soma, and the axon.
An artificial neuron is a mathematical abstraction that receives inputs, applies weights, adds a bias, and computes a weighted sum:
The weighted sum is passed through an activation function:
Activation functions such as sigmoid, ReLU, tanh, and softmax determine how the neuron transforms its input.
The most important reason activation functions are needed is that they introduce non-linearity into neural networks. This allows multiple layers to learn complex relationships that cannot be represented by a single linear transformation.
A single perceptron can solve linearly separable problems such as AND and OR, while multi-layer neural networks can represent much more complex functions.
The fundamental computation to remember is:
This equation forms the basic building block from which larger neural networks are constructed.
Next Topics
After understanding biological neurons, artificial neurons, and activation functions, the next important topics are:
- Multi-Layer Perceptron (MLP)
- Forward Propagation
- Loss Functions
- Gradient Descent
- Backpropagation
- Training Neural Networks
- Overfitting and Regularization
- Optimizers such as SGD and Adam
- Deep Neural Networks
- Convolutional and Recurrent Neural Networks