Artificial Neural Networks
Artificial Neural Networks: Foundations, Architecture, and Training
1. What Artificial Neural Networks Do
Artificial neural networks are computational models inspired by the way the biological nervous system processes information. They are used to identify patterns, make predictions, and support decisions in applications such as:
ChatGPT and other generative AI systems
Gemini and similar language models
Tesla’s self-driving systems
Bank fraud-detection systems
Enterprise-level prediction and classification systems
Image, text, speech, and numerical-data analysis
A neural network receives input data, processes it through connected computational units called neurons, and produces an output or decision.
A neural network learns by adjusting the importance assigned to different inputs until its predictions become increasingly accurate.
2. Biological Inspiration: The Nervous System
The basic idea behind an artificial neural network comes from the human nervous system.
Example: Reacting to a Fast-Moving Car
Suppose a car is approaching a person at high speed:
The person’s eyes detect the car.
The person’s ears may hear the car’s sound.
These signals are transmitted to neurons in the nervous system.
The neurons process the incoming information.
Certain neurons become activated.
The person decides to jump away from the car.
The decision depends on which neurons become activated after processing the sensory inputs.
Example: Feeling Relaxed
When a person sits on a sofa and listens to melodious music:
The ears receive sound signals.
The signals are transmitted to neurons.
The neurons process the signals.
A different group of neurons becomes activated.
The person experiences relaxation.
The two situations activate different neurons and lead to different decisions or emotional responses.
Connection to Artificial Neural Networks
Artificial neural networks imitate this general pattern:
Inputs are equivalent to sensory signals.
Neurons perform calculations on the inputs.
Activation determines whether a neuron contributes strongly to the next stage.
Outputs represent a prediction or decision.
The central question is:
How does a neural network calculate which neurons should become activated?
The answer involves inputs, weights, biases, mathematical transformations, activation functions, loss functions, and optimization.
3. High-Level Architecture of a Neural Network
A basic artificial neural network contains three main types of layers:
Input layer
Hidden layer or layers
Output layer
Information generally moves from the input layer toward the output layer during forward propagation.
3.1 Input Layer
The input layer receives the data used by the neural network.
For example, a person’s health-related data might contain:
Weekly exercise hours
Weekly junk-food consumption
Daily sleeping hours
Daily water consumption in liters
Each measurable property is called a feature.
If there are four features, the input layer can contain four input neurons:
x1: exercise data
x2: junk-food data
x3: sleep data
x4: water-consumption data
The input layer generally does not perform the main mathematical processing. Its primary role is to receive the feature values and pass them to the next layer.
3.2 Hidden Layer
The hidden layer performs most of the intermediate processing.
A neural network may contain:
One hidden layer
Several hidden layers
Many neurons in each hidden layer
A network with many hidden layers is commonly called a deep neural network, which is the basis of deep learning.
Every neuron in an input layer may be connected to neurons in the next hidden layer. These connections carry values that are adjusted during training.
For simplicity, an example may use:
Four input neurons
One hidden layer
Two hidden neurons
One output neuron
The hidden neurons do not directly represent obvious concepts such as “fit” or “unfit.” Instead, they learn intermediate patterns by combining the input features.
3.3 Output Layer
The output layer produces the final prediction or decision.
For the health example, the output could represent whether a person is fit:
Output value near 1: fit
Output value near 0: unfit
The output layer receives the processed values from the previous hidden layer, performs another calculation, and applies an appropriate activation function.
4. Example: Predicting Whether a Person Is Fit
4.1 Features and Label
Suppose the dataset contains information about many people. Each record includes four features:
Hours of exercise per week
Number of times junk food is eaten per week
Hours of sleep per day
Liters of water consumed per day
The target label indicates whether the person is fit:
1: fit
0: unfit
The four features are used to predict the label.
This is a binary classification problem because there are only two possible categories.
Binary classification predicts one of two possible outcomes, commonly represented by 0 and 1.
4.2 Labeled Training Data
During training, the neural network receives both:
The input features
The correct label
For example, a training record might be represented as:
The exact values are less important than the process. The network initially does not know:
Which feature is important
Whether a feature should increase or decrease the prediction
How the features should be combined
Whether the person is fit or unfit
It must learn these relationships from examples.
After training, the network should be able to receive the features of a new person without the label and predict whether that person is fit.
5. Weights: Assigning Importance to Inputs
Each connection between neurons has an associated weight.
A weight controls how strongly an input affects the calculation of the next neuron.
A large positive weight gives an input strong positive influence.
A small positive weight gives an input weak positive influence.
A negative weight gives an input negative influence.
A weight near zero gives an input little influence.
For example, if junk-food consumption is expected to reduce the probability of being fit, the corresponding weight may eventually become negative.
Initial Weights
At the beginning of training, the neural network does not know the correct importance of any feature. Therefore, the weights are usually initialized with small random values.
The network gradually changes these weights during training.
Weights represent the learned importance of inputs in a neural network.
6. Calculations Inside a Neuron
A neuron combines its input values and weights. The first calculation is a weighted sum followed by the addition of a bias.
For inputs x1,x2,…,xn and corresponding weights w1,w2,…,wn, the calculation is:
This can be written more compactly as:
where:
xi is an input feature
wi is the weight associated with that feature
b is the bias
z is the neuron’s weighted-sum result before activation
The source describes an example in which this calculation produces a value such as:
The value is not yet the final output of the neuron. It must be passed through an activation function.
6.1 Bias
A bias is an additional value added to the weighted sum.
It allows the neuron to shift its output independently of the input values. Without a bias, the neuron would be more restricted in the mathematical functions it could represent.
The bias is also learned during training. It may initially be assigned a small value, such as 0.2 or 0.3, depending on the example.
The complete neuron calculation is therefore:
7. Activation Functions
The weighted sum z can be positive or negative. An activation function transforms this value and determines how strongly the neuron should be activated.
Activation functions are important because they:
Determine whether a neuron contributes to later calculations
Introduce nonlinearity into the network
Help the network learn complex relationships
Produce outputs suitable for different prediction tasks
Two activation functions discussed are ReLU and sigmoid.
7.1 ReLU Activation Function
ReLU stands for Rectified Linear Unit.
Its definition is:
This means:
If z is positive, ReLU returns z.
If z is negative, ReLU returns 0.
For example:
If the weighted sum were −3, then:
Interpretation
A positive weighted sum produces a positive activated value. A negative weighted sum is suppressed to zero.
In the hidden layer, ReLU allows positive signals to continue while preventing negative signals from contributing to the next stage.
ReLU preserves positive values and converts negative values to zero.
7.2 Hidden-Layer Example
Suppose the first hidden neuron receives the input values and weights, producing:
After applying ReLU:
The neuron is therefore active and passes 11.15 to the next layer.
A second hidden neuron has different weights, so it produces a different value. For example:
After ReLU:
Both hidden neurons are active in this example, but their activation values differ because they use different weights and biases.
8. Processing in the Output Layer
The output layer receives the activated values from the hidden layer.
If the hidden layer produces a1 and a2, the output layer calculates another weighted sum:
The output layer also has weights and a bias. These values are initially random and are learned during training.
For example, the output-layer calculation may produce:
Because this is a binary classification task, the output should be converted into a value between 0 and 1. The sigmoid activation function is appropriate for this purpose.
9. Sigmoid Activation Function
The sigmoid function is defined as:
It converts any real-valued input into a number between 0 and 1.
The sigmoid function is useful for binary classification because its output can be interpreted as a probability-like value.
For example:
Output near 0: strong evidence for class 0
Output near 1: strong evidence for class 1
Output near 0.5: uncertain prediction
If the output layer produces:
then the sigmoid output is very close to 1, approximately:
9.1 Thresholding the Sigmoid Output
A common decision rule is:
If the sigmoid output is between 0 and 0.5, classify the example as 0.
If the sigmoid output is between 0.5 and 1, classify the example as 1.
Thus:
where y^ is the predicted output.
For the fitness example:
y^≥0.5: predict fit
y^<0.5: predict unfit
An output of 0.99 indicates a strong prediction for class 1, although it does not guarantee perfect correctness.
The closer a sigmoid output is to 1, the stronger the model’s confidence in class 1; the closer it is to 0, the stronger the confidence in class 0.
10. Forward Propagation
Forward propagation is the process through which input data moves from the input layer to the output layer.
The process is:
Feature values enter the input layer.
The input values are multiplied by connection weights.
The weighted values are added together with a bias.
An activation function is applied in the hidden layer.
The activated hidden-layer values are passed to the output layer.
The output layer calculates another weighted sum.
An output activation function, such as sigmoid, produces the final prediction.
The general flow is:
Forward propagation produces a prediction, but it does not by itself tell the network whether the prediction is correct. That requires a comparison with the actual label.
11. Implementing Neural Networks with Libraries
Although the underlying calculations involve many formulas, deep-learning libraries perform most of them automatically.
Common libraries include:
TensorFlow
Keras
PyTorch
A neural-network implementation can specify:
The number of layers
The number of neurons
The activation function for each layer
The loss function
The optimizer
For example, a network may specify:
ReLU for a hidden layer
Sigmoid for a binary-classification output layer
The library then performs the repeated mathematical operations required for forward propagation, loss calculation, backpropagation, and weight updates.
Understanding the mathematics remains important because it helps a practitioner:
Choose appropriate activation functions
Select a suitable loss function
Select an optimizer
Diagnose training problems
Understand how the model learns
Improve the network’s performance
The library automates the calculations, but it does not eliminate the need to understand the underlying concepts.
12. Loss Functions
After forward propagation, the neural network has a prediction, but the prediction must be compared with the correct label.
A loss function measures the difference between:
The actual output, represented by y
The predicted output, represented by y^
The loss value indicates how incorrect the prediction is.
Loss close to 0: prediction is close to the expected result
Large loss: prediction is far from the expected result
The network uses the loss to determine how its weights should be changed.
12.1 Binary Cross-Entropy
For binary classification, a suitable loss function is binary cross-entropy:
where:
y is the actual label
y^ is the predicted probability
L is the loss
Binary cross-entropy strongly penalizes confident incorrect predictions.
Example of a Correct Positive Prediction
If the actual label is y=1 and the network predicts y^=0.99, the loss is small:
This is close to zero because the prediction is close to the correct value.
Example of an Incorrect Positive Prediction
If the actual label is y=1 but the network predicts y^=0.1, the loss is much larger:
The network is confidently moving toward the wrong class, so it receives a substantial penalty.
Important Note About Prediction Values
The size of the loss depends on both the actual label and the predicted value. For example, if the actual label is y=0 and the prediction is y^=0.99, the prediction is very wrong and the loss is high. If the actual label is y=1, the same prediction is very good and the loss is low.
Therefore, a prediction such as 0.99 cannot be judged as correct or incorrect without knowing the actual label.
13. Backpropagation
Backpropagation is the process of sending error information backward through the network.
After forward propagation:
The network produces a prediction.
The prediction is compared with the actual label.
A loss value is calculated.
The loss information is propagated backward through the layers.
The contribution of each weight to the loss is estimated.
The weights and biases are adjusted.
Backpropagation allows the network to determine which connections contributed to the error and by how much.
Forward propagation produces the prediction; backpropagation uses the prediction error to improve the network.
14. Gradient Descent and Weight Updates
Backpropagation provides information about how each parameter affects the loss. Gradient descent uses that information to update the parameters.
A basic weight-update equation is:
where:
wold is the current weight
wnew is the updated weight
η is the learning rate
L is the loss
∂w∂L is the derivative of the loss with respect to the weight
The derivative indicates how much the loss changes when the weight changes.
14.1 Derivatives
The derivative is not ordinary division. It comes from differential calculus.
The quantity:
indicates how strongly a particular weight contributes to the loss.
A large derivative means the weight has a strong effect on the loss.
A small derivative means the weight has a weaker effect.
The sign indicates the direction in which the weight should change.
For example, if a junk-food feature has a positive weight but should negatively influence fitness, gradient descent may reduce the weight and eventually make it negative.
14.2 Example of a Weight Update
Suppose:
The old weight is wold=0.5
The learning rate is η
The calculated gradient has a particular value
The update follows:
The source describes an example in which a weight is updated from a positive value to approximately:
This means the network learned that the associated feature should influence the prediction in the negative direction.
For the fitness example, high junk-food consumption may eventually receive a negative weight because it tends to reduce the probability of being classified as fit.
15. The Learning Rate
The learning rate determines the size of each parameter update.
It controls how far the network moves in the direction suggested by the gradient.
15.1 Learning Rate That Is Too Small
If the learning rate is too small:
The weights change very gradually.
The loss decreases slowly.
Training may require many iterations.
The network may take a long time to reach a good solution.
15.2 Learning Rate That Is Too Large
If the learning rate is too large:
The updates may overshoot the best parameter values.
The loss may move back and forth.
Training may oscillate instead of converging.
The model may fail to approach a low-loss solution.
15.3 Appropriate Learning Rate
A suitable learning rate allows the loss to decrease steadily:
The network makes a prediction.
The loss is calculated.
The weights are adjusted by a controlled amount.
The next prediction is slightly better.
The process continues until the model reaches a low-loss region.
The goal is to reduce the loss as close to zero as practical without making the updates unstable.
16. Complete Neural-Network Training Process
Training combines forward propagation, loss calculation, backpropagation, and gradient descent.
The full process is:
Initialize the weights and biases, usually with small random values.
Pass a labeled training example into the input layer.
Perform forward propagation.
Calculate the predicted output.
Compare the prediction with the actual label.
Calculate the loss using binary cross-entropy.
Perform backpropagation.
Calculate how each weight contributed to the loss.
Update the weights and biases using gradient descent.
Repeat the process for additional training examples.
Continue over many passes through the data.
Evaluate the trained model on new, unlabeled data.
The repeated passes allow the network to gradually learn useful weights.
16.1 Training Across Many Examples
A single training example is not enough for a reliable model. The network must process many examples:
Hundreds of examples
Thousands of examples
Millions of examples, depending on the task
With repeated training, the model adjusts its weights to capture general relationships in the data rather than memorizing only one record.
After training, the result is a generalized model. It can accept new input data and produce predictions even when the correct label is not provided.
The predictions may be highly accurate, but no neural network is guaranteed to be correct 100% of the time.
17. Choosing Functions for Different Tasks
Neural-network design requires selecting suitable functions for the problem.
Important choices include:
Activation functions
Loss functions
Optimizers
Hidden-Layer Activation
ReLU is commonly used in hidden layers because it is simple and preserves positive signals while suppressing negative ones.
Binary-Classification Output
Sigmoid is suitable when the output represents one of two classes because it produces values between 0 and 1.
Binary-Classification Loss
Binary cross-entropy is appropriate when the target contains two classes and the output is a probability-like value.
Optimizer
Gradient descent and related optimization methods update the weights to reduce the loss.
The correct choices depend on the type of data and prediction task. For example, binary classification and multi-class classification generally require different output configurations.
18. Neural Networks Process Numerical Inputs
Neural networks operate on numbers.
Even when the original data is not naturally numerical, it must be transformed into numerical representations before being passed into a neural network.
Examples include:
Tabular data represented as feature values
Images represented as pixel values
Text represented as numerical vectors
Audio represented as numerical signals
This explains why image classification requires a preprocessing step: an image must be converted into numerical pixel data before the neural network can process it.
19. Binary Classification and Multi-Class Classification
Binary Classification
Binary classification has two possible outcomes.
Example:
Fit: 1
Unfit: 0
A sigmoid output neuron is commonly used for this type of task.
Multi-Class Classification
Multi-class classification has more than two possible outcomes.
A handwritten-digit recognizer that identifies digits from 0 through 9 has ten possible classes:
The neural network must determine which of the ten classes best matches the input image.
This is different from the fitness example because the network is no longer choosing between only two outcomes. Its output design and activation function are therefore adapted to the multi-class problem.
The general learning process remains similar:
Convert the input into numerical form.
Perform forward propagation.
Produce class-related outputs.
Compare the prediction with the correct class.
Calculate loss.
Backpropagate the error.
Update the weights.
20. Key Relationships Among the Main Concepts
Inputs are the feature values provided to the network.
Weights determine how strongly each input influences a neuron.
Biases shift the weighted-sum calculation.
Weighted sums combine inputs and weights.
Activation functions determine the signal passed to the next layer.
Forward propagation carries information from input to output.
Predictions are the output of the final layer.
Loss functions measure prediction error.
Backpropagation determines how the error affects the network’s parameters.
Gradients describe how parameter changes affect the loss.
Gradient descent updates weights to reduce the loss.
Repeated training produces a model that can generalize to new data.
A neural network learns by repeatedly predicting, measuring its error, tracing that error backward, and adjusting its weights.
21. Summary
An artificial neural network is a layered computational system inspired by biological neurons. It receives numerical input through an input layer, processes the information through one or more hidden layers, and produces a prediction through an output layer.
Each neuron calculates a weighted sum:
The result is passed through an activation function such as ReLU:
or sigmoid:
For binary classification, sigmoid produces an output between 0 and 1. The prediction is compared with the actual label using binary cross-entropy. Backpropagation then calculates how the weights contributed to the error, and gradient descent updates them:
By repeating this process over many examples, the network gradually learns useful relationships among the features and becomes capable of making predictions on new data.

Ask anything
We've read this whole study set, so questions about it get the best answers.