> For the complete documentation index, see [llms.txt](https://riteshs4hu.gitbook.io/infosec-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://riteshs4hu.gitbook.io/infosec-notes/artificial-intelligence/machine-learning-ml/deep-learning.md).

# Deep Learning

Deep Learning is a subset of Machine Learning that utilises multi-layered neural networks to model and learn complex patterns from data. It is particularly effective in processing unstructured data such as images, audio, and video, due to its ability to automatically extract hierarchical features.

***

## **Neural Network**

A **Neural Network** is a computational model inspired by the human brain. It consists of interconnected units called **neurons**, organised into layers.

### Structure of a Neural Network

A basic neural network contains three main layers:

**Input Layer**

* Receives the input data.
* Each neuron represents one feature of the dataset.

**Hidden Layer(s)**

* Perform intermediate computations.
* Extract patterns and relationships from input data.
* A deep network contains multiple hidden layers.

**Output Layer**

* Produces the final prediction or result.
* Output may be:
  * A class label (e.g., Spam / Not Spam)
  * A numerical value (e.g., price prediction)

***

### Neuron

A **neuron** is the fundamental unit of a neural network. Each neuron performs a mathematical computation.

Each neuron:

1. Receives inputs
2. Multiplies each input by a weight
3. Adds a bias
4. Applies an activation function
5. Produces an output

#### Mathematical Representation

\
Z = (x\_1w\_1 + x\_2w\_2 + x\_3w\_3 + ... + b)

Then the activation function is applied:

\
Output = f(Z)

Where:

* (x) = Input values
* (w) = Weight parameters
* (b) = Bias
* (f) = Activation function

***

### Weight Parameters

Weights are learnable parameters that determine the importance of each input feature.

* Higher weight → More influence
* Lower weight → Less influence

During training, weights are adjusted to minimise prediction error.

***

## How a Neural Network Works

The working process can be summarised as:

Input → Weighted Computation → Activation → Output → Adjust Weights → Improve Prediction

Training a neural network involves two major steps:

### Forward Propagation

* Input data passes through the network layer by layer.
* Each neuron performs a weighted sum + activation.
* The final output (prediction) is produced.

### Backward Propagation

* The predicted output is compared with the expected (true) value.
* The difference is calculated using a **loss function**.
* The error is propagated backwards through the network.
* Weights are updated using optimisation techniques (e.g., Gradient Descent).
* The goal is to minimise the loss.

This process repeats until the model achieves acceptable accuracy.

***

## Neural Network Architectures

Different types of neural networks are designed for different tasks:

* **FFNN (Feed Forward Neural Network)**\
  A basic network where data flows in one direction.
* **RNN (Recurrent Neural Network)**\
  Designed for sequential data (text, speech).
* **CNN (Convolutional Neural Network)**\
  Used mainly for image processing.
* **Transformers**\
  Advanced architecture used in modern NLP and Large Language Models.

***

#### Tools Used for Deep Learning

Common frameworks and platforms include:

* TensorFlow
* PyTorch
* Keras
* Kaggle (for datasets and competitions)

***

#### Reference:

* <https://youtu.be/D1eL1EnxXXQ>
* <https://www.ibm.com/think/topics/neural-networks#741977106>
