DL Notes
Complete guide to Artificial Neural Networks — understanding architecture, how information flows through layers, and building your first network from scratch.
An Artificial Neural Network is a computational model inspired by the human brain — a collection of interconnected nodes (neurons) organized in layers that learn to map inputs to outputs by adjusting connection strengths (weights). It's the fundamental building block of all deep learning.
Architecture Overview
Every feedforward neural network has three types of layers:
- Input layer: Receives raw features (pixel values, word embeddings, numerical data)
- Hidden layers: Transform representations through learned weights + non-linear activations
- Output layer: Produces final predictions (class probabilities, regression values)
How a Single Neuron Works
Each neuron performs three operations:
- Weighted sum: Multiply each input by its weight and sum
- Add bias: Shift the sum by a learnable bias term
- Activation: Apply a non-linear function
$$z = \sum_{i=1}^{n} w_i x_i + b = \mathbf{w}^T\mathbf{x} + b$$
$$a = \sigma(z)$$
Where σ is an activation function (ReLU, sigmoid, tanh).
import numpy as np
def neuron(x, w, b, activation='relu'):
"""Single neuron computation"""
z = np.dot(w, x) + b # Linear transformation
if activation == 'relu':
return max(0, z)
elif activation == 'sigmoid':
return 1 / (1 + np.exp(-z))
elif activation == 'tanh':
return np.tanh(z)Why Multiple Layers?
A single neuron can only learn linear decision boundaries. Stacking layers with non-linear activations allows the network to learn arbitrarily complex functions.
Universal Approximation Theorem: A neural network with at least one hidden layer and a non-linear activation can approximate any continuous function to arbitrary precision (given enough neurons).
However, depth is more efficient than width — a deep network with fewer total neurons can represent functions that a shallow network would need exponentially many neurons to learn.
Building an ANN from Scratch
Building with PyTorch
Design Decisions
How Many Hidden Layers?
- 1 layer: Simple problems, tabular data
- 2-3 layers: Most practical applications
- 5+ layers: Complex patterns, large datasets (use skip connections)
How Many Neurons Per Layer?
- Start with a "funnel" shape: wide early, narrow later (e.g., 512→256→128)
- Too few = underfitting, too many = overfitting and slow training
- Rule of thumb: between input size and output size
Which Activation Function?
- Hidden layers: ReLU (default), LeakyReLU if dying ReLU is a problem
- Output layer: Softmax (multi-class), Sigmoid (binary), Linear (regression)
Common Pitfalls
| Problem | Symptom | Solution |
|---|---|---|
| Vanishing gradients | Deep layers don't learn | ReLU, skip connections, BatchNorm |
| Exploding gradients | Loss becomes NaN | Gradient clipping, proper initialization |
| Overfitting | Train acc high, val acc low | Dropout, regularization, more data |
| Underfitting | Both accuracies low | More layers/neurons, lower regularization |
Key Takeaways
- ANNs learn by adjusting weights through forward propagation → loss computation → backpropagation
- Non-linear activations are essential — without them, stacking layers is pointless (linear of linear = linear)
- Deeper networks are more efficient than wider ones for complex functions
- Weight initialization, batch normalization, and proper activation functions are crucial for training stability
- Start simple (2-3 layers) and only add complexity if the model underfits
Exam Focus
Revise definitions, diagrams, examples, and short-answer points for Artificial Neural Networks (ANN).
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this Deep Learning topic.
Search Terms
deep-learning, deep learning, deep, learning, neural, network, fundamentals, artificial
Related Deep Learning Topics