🤖 AI Fundamentals

Module 3: Neural Networks & Deep Learning

📚 Learning Objectives

  • Understand how artificial neural networks mimic the human brain
  • Learn the structure: neurons, layers, weights, biases, activation functions
  • Understand backpropagation and how networks learn
  • Explore different neural network architectures: CNN, RNN, transformers
  • Learn applications: image recognition, NLP, speech recognition
  • Understand computational requirements and training challenges

🎥 Learning Videos

1. Neural Networks Explained - How They Work

Farmworx KenyaHow to Grow Maize for High Yields |Expert Free Guide on Maize Farming in Kenya
This lesson's video moved.
Find it on YouTube →

2. Backpropagation: How Neural Networks Learn

Farm With FredMaize Farming: The Ultimate Guide to Spacing & Preparation
This lesson's video moved.
Find it on YouTube →

3. Convolutional Neural Networks (CNN) for Images

Farm With FredMaize Farming: The Ultimate Guide to Spacing & Preparation
This lesson's video moved.
Find it on YouTube →

4. Recurrent Neural Networks (RNN) for Sequences

CSIR-SARIMaize Land Preparation Techniques
This lesson's video moved.
Find it on YouTube →

5. Transformers & Attention Mechanism - Modern Deep Learning

THE FARM CHIEFMAIZE SPACING WHEN PLANTING FOR HIGH YIELDS
This lesson's video moved.
Find it on YouTube →

📊 Neural Network Architectures & Applications

ArchitectureStructureBest ForKey ExampleComputational Cost
Feedforward NNInput → Hidden Layers → OutputBasic classification/regressionSpam detection, credit scoringLow-Medium
CNN (Convolutional)Convolutional layers find patterns in imagesImage recognition, computer visionFacial recognition, medical imagingMedium-High
RNN (Recurrent)Loops allow processing sequencesText, time series, languageMachine translation, speech recognitionMedium-High
LSTM/GRURNN variant that remembers long-term contextLong sequences, dependency learningLanguage models, stock predictionMedium-High
TransformerAttention mechanism processes all positions simultaneouslyLanguage (most efficient)ChatGPT, BERT, GPT-4Very High (billions of parameters)

📋 6 Neural Network Concepts

Concept 1: Neurons & Activation Functions

NEURON: receives multiple inputs, multiplies each by a weight, sums them, applies activation function, produces output. Activation function adds NON-LINEARITY (sigmoid, ReLU, tanh). Without it, deep networks collapse to single linear layer (useless). ReLU (Rectified Linear Unit) most popular: returns max(0, x). Allows network to learn complex patterns.

Concept 2: Layers & Network Depth

INPUT LAYER: raw data (e.g., pixel values). HIDDEN LAYERS: learn intermediate representations. OUTPUT LAYER: final prediction. "Deep" learning = many hidden layers (10+, sometimes 100+). Deeper networks can learn more complex patterns BUT require more data and training time. Trade-off: depth vs. generalization.

Concept 3: Backpropagation & Gradient Descent

BACKPROPAGATION: algorithm that calculates how much each weight contributed to error. Then adjusts weights to reduce error. Repeated thousands of times (epochs). GRADIENT DESCENT: direction to adjust weights. Think: walk downhill to find valley (minimum error). Learning rate: size of steps (too big = overshoot, too small = slow).

Concept 4: CNNs - Convolutional Layers & Filters

CONVOLUTIONAL LAYER: small "filter" scans image looking for patterns (edges, shapes, textures). First layer finds simple edges, second finds shapes, third finds objects. POOLING: reduces image size, keeps important features. Example: 224x224 image → multiple layers → 1000 output classes (ImageNet). Conv layers are FEATURE EXTRACTORS, final layer is CLASSIFIER.

Concept 5: RNNs - Recurrent Connections & Memory

RECURRENT: output feeds back as input (has memory of previous steps). Good for sequences where order matters. Problem: VANISHING GRADIENT - gradients get too small, network forgets long-term context. Solution: LSTM (Long Short-Term Memory) and GRU - special cells with gates that control information flow. Modern RNNs can remember 100+ steps.

Concept 6: Transformers & Attention Mechanism

ATTENTION: each word attends to all other words, learns relationships. PARALLELIZABLE: unlike RNNs (must process sequentially), transformers process all positions simultaneously = MUCH FASTER training. Key innovation: scaled dot-product attention. This is what powers ChatGPT - transformer architecture with billions of parameters trained on internet-scale data.

🎯 Module 3 Quiz

1. What is the purpose of activation functions in neural networks?

2. What is backpropagation?

3. What advantage do transformers have over RNNs?

🚀 Real-World Project: Understanding Neural Network Architectures

Part 1: Image Recognition with CNNs

Study a pretrained CNN (ImageNet model). Document: layer-by-layer transformations, what patterns each layer detects, final classification. Test with different images: does it work? Where does it fail?

Part 2: NLP with Transformers

Explore how transformers process text (ChatGPT architecture). Document: how attention mechanism works, why it's better than RNNs, what this enables. Test with prompts: how good is generation? What limitations?

Part 3: Computational Requirements Analysis

Research compute needed for different models: ResNet-50 (images) vs GPT-3 (language). Compare: parameters, training time, GPU memory, inference cost. Why do large models require massive compute? Carbon footprint implications?

Part 4: From Theory to Practice

If you were training a neural network for your problem: what architecture? Why? Estimated parameters? GPU requirements? Training time? This forces you to think practically about deep learning deployment.

Part 5: Model Interpretability Challenge

"Black box" problem: deep networks are hard to interpret. Research explainability methods: saliency maps, attention visualization, LIME. Demonstrate on image: which pixels matter for classification? Can you understand the model's reasoning?

Part 6: Ethics of Foundation Models

ChatGPT, GPT-4 etc. trained on internet data. Research: what biases exist? Plagiarism/copyright concerns? Environmental cost? Create report: if you were deploying this, what safeguards needed?

Part 7: Practical Implementation

Use PyTorch or TensorFlow to implement simple feedforward network. Train on MNIST (handwritten digits). Code task: 3-4 layers, ReLU activation, Adam optimizer. Achieve 95%+ accuracy. Document learning process.

Part 8: Scaling & Transfer Learning

Research transfer learning: why take pretrained ImageNet model and fine-tune? How does it save time/data? When would you use vs. training from scratch? Create decision tree: your problem → recommend architecture + training approach.

Ready to continue? Move to Module 4: Natural Language Processing & Large Language Models

→ Next Module