π What is an ANN?
An Artificial Neural Network (ANN) is a computational model inspired by the way biological neurons in the human brain work.
It consists of layers of interconnected nodes (neurons) that process data, learn patterns, and make predictions.
π Structure of an ANN
- Input Layer
- Receives raw features (e.g., pixel values in an image, sensor readings, text embeddings).
- Each neuron represents one input feature.
- Hidden Layers
- Perform transformations on input data using weights, biases, and activation functions.
- Can be one (shallow ANN) or many (deep ANN).
- Output Layer
- Produces the final prediction.
- For classification β probabilities for each class.
- For regression β continuous value.
π How ANN Works (Step-by-Step)
- Weighted Sum
Each neuron calculates: z=β(wiβ xi)+bz = \sum (w_i \cdot x_i) + bz=β(wiββ xiβ)+b where www = weight, xxx = input, bbb = bias. - Activation Function
Applies a non-linear transformation (e.g., ReLU, Sigmoid, Tanh) so the network can model complex patterns. - Forward Propagation
Input flows layer by layer until an output is generated. - Loss Function
Measures how far predictions are from actual values (e.g., MSE, Cross-Entropy). - Backpropagation
Computes gradients of the loss w.r.t. weights and biases. - Weight Update
Uses Gradient Descent (or variants like Adam) to minimize loss.
π Types of Neural Networks
- Feedforward ANN (FNN): Simple one-directional flow (no loops).
- Convolutional Neural Network (CNN): Specialized for images & computer vision.
- Recurrent Neural Network (RNN): Good for sequential data (speech, text, time-series).
- Deep Neural Network (DNN): Many hidden layers (deep learning).
π Example: ANN for Spam Detection
- Input Layer: Email features (keywords, frequency, sender info).
- Hidden Layers: Extract relationships (e.g., “free money” + “click link”).
- Output Layer: 0 = Not Spam, 1 = Spam.
π ANN Architecture Diagram (Conceptual)
Input Layer β Hidden Layer(s) β Output Layer
x1 βββΆ βββββΆ β
x2 βββΆ βββββΆ βββββΆ y (prediction)
x3 βββΆ βββββΆ β
π Advantages of ANN
β
Learns complex non-linear patterns
β
Adaptable across domains (vision, NLP, speech, healthcare, finance)
β
Improves with large datasets
π Challenges of ANN
β Requires lots of data and computation power
β Difficult to interpret (“black box”)
β Risk of overfitting if not regularized
π Analogy:
- ANN is like a brain-inspired calculator:
- Neurons (nodes) = tiny decision makers.
- Synapses (weights) = connection strengths.
- Learning = adjusting connections until predictions are accurate.