Machine Learning Concepts Guide
Table of Contents
- Performance Metrics
- Datasets
- Tools & Frameworks
- Training Concepts
- Neural Network Fundamentals
- Model Optimization
- Advanced Architectures
Performance Metrics
FLOPS (Floating-Point Operations)
Hardware FLOPS: Floating-Point Operations Per Second - measures computational speed
Model FLOPS: Floating-Point Operations - measures computational complexity
Simple Definition: FLOPS = how much work the model does when processing one image
Think of it as counting how many billion mathematical operations your model performs for a single forward pass (one input image).
Datasets
Popular Public Datasets
| Dataset | Size | Categories | Description |
|---|---|---|---|
| ImageNet | 14 million images | 20,000 categories | General object recognition |
| COCO | Various sizes | 80 object types | Common Objects in Context |
| CIFAR-10/100 | 60,000 images | 10/100 categories | 32×32 pixel images (Canadian Institute For Advanced Research) |
| DOTA | Various | 15 categories | Dataset for Object Detection in Aerial Images |
| Fashion-MNIST | 60,000 images | 10 categories | Fashion product images |
Tools & Frameworks
TorchVision
TorchVision is PyTorch's computer vision library that simplifies development with:
- Pre-trained Models: ResNet, VGG, Inception, and more
- Built-in Datasets: CIFAR-10, CIFAR-100, COCO, MNIST, etc.
- Data Transformations: Resizing, cropping, rotation, normalization, quality enhancement
- Detection & Segmentation: Faster R-CNN, Mask R-CNN implementations
YAML Configuration Files
YAML (YAML Ain't Markup Language) is the preferred format for configuration files due to: - Python-like syntax with meaningful whitespace - Better readability than JSON - More user-friendly structure
Example YAML Configuration:
# Project configuration
company: spacelift
domain:
- devops
- devsecops
tutorial:
- yaml:
name: "YAML Ain't Markup Language"
type: awesome
born: 2001
- json:
name: JavaScript Object Notation
type: great
born: 2001
- xml:
name: Extensible Markup Language
type: good
born: 1996
author: omkarbirade
published: true
Training Concepts
Epochs
Definition: One complete pass through the entire training dataset where every sample is processed and model parameters are updated based on calculated error.
Why Multiple Epochs? The model improves iteratively, adjusting parameters with each pass to minimize prediction errors.
Weights
Purpose: Weights determine how strongly each input influences the final output.
Example: In a course grading prediction model, different factors (marital status, trade, location) are multiplied by specific weights based on their importance to the final grade.
How They Work: 1. During forward propagation, inputs are multiplied by their weights 2. Results pass through an activation function 3. Weights are updated during training via gradient descent 4. Goal: Minimize difference between predicted and actual outcomes
Bias
Analogy: Think of bias as your default emotional state before anything happens in your day. Events (inputs) push you up or down from this starting point.
Mathematical Representation:
y = mx + b
- m = weight (slope)
- x = input
- b = bias (starting point)
Neural Network Fundamentals
Activation Functions
Purpose: The "decision-making" step that determines whether a neuron should activate.
Analogy: Like your brain deciding "Should I go outside?" based on total influence of weather, mood, and time. If the combined score exceeds your threshold (say, 50), you go outside.
Common Types: - ReLU (Rectified Linear Unit) - Most popular for hidden layers - Softmax - Used in output layer for classification
Neural Network Layers
Structure: 1. Input Layer: Receives raw data 2. Hidden Layers: Apply mathematical transformations 3. Output Layer: Produces final predictions
Back Propagation: The learning process where the network adjusts weights to improve accuracy.
Model Optimization
Quantization
Definition: Compressing a trained model by converting 32-bit floating-point numbers to smaller representations (typically 8-bit integers).
Why Quantize? - Faster inference - Lower memory usage - Easier deployment on edge devices
Types of Quantization:
| Type | What's Quantized | Pros | Cons |
|---|---|---|---|
| Dynamic | Weights only (int8) | Fast, easy to implement | Moderate accuracy |
| Static | Weights + activations (int8) | Better accuracy | More complex setup |
| QAT (Quantization Aware Training) | Trained with quantization | Best accuracy | Slower training |
Note: For YOLO models, dynamic or static quantization is commonly applied post-training.
ONNX (Open Neural Network Exchange)
Purpose: A universal format for neural networks - like exporting a Word document as PDF so any device can open it the same way.
Benefits: - Cross-platform compatibility - Framework interoperability - Simplified deployment
Advanced Architectures
Transformer Networks
What They Are: Neural networks designed for sequential data (text, audio, time series).
Key Advantages: - Process data in parallel (much faster than RNNs) - Can handle long-range dependencies - State-of-the-art performance on NLP tasks
Key Concepts:
1. Self-Attention Mechanism
Analogy: Like being in a busy room and selectively focusing on one conversation while filtering out background noise.
Example: Understanding "The trophy wouldn't fit in the suitcase because it was too big." - What does "it" refer to? - Self-attention helps the model understand "it" refers to the trophy, not the suitcase
2. Positional Encoding
Why Needed: Since Transformers process all words simultaneously, they need explicit position information.
Example: Without positional encoding: - "dog bites man" = "man bites dog" (completely different meanings!)
3. Multi-Head Attention
Analogy: Like having multiple people read the same text, each focusing on different aspects: - Person 1: Syntactic relationships (grammar) - Person 2: Semantic similarities (meaning) - Person 3: Subject-object relationships
GPT: Generative Pre-trained Transformer - a specific type of Transformer architecture
Encoder-Decoder Architecture
Components: - Encoder: Processes input and creates a representation - Decoder: Takes the representation and generates output
Neural Network Types Comparison
| Type | Best For | Example Use Cases |
|---|---|---|
| CNN (Convolutional Neural Network) | Images, spatial data | Object detection, image classification |
| RNN (Recurrent Neural Network) | Sequential data | Time series, simple text tasks |
| Transformer | Sequential data | Language models, translation, complex NLP |
Visual Question Answering (VQA) Models
What Are VQA Models?
Input: Image + Text question Output: Text-based answer
Example Questions: - "What is the color of the car in the image?" - "Is the person on the bike wearing a helmet?"
Architecture
VQA models use a multi-modal architecture combining: 1. Vision Component: CNN or Vision Transformer for image understanding 2. Language Component: LLM for text processing and generation 3. Fusion Layer: Combines visual and textual information
Popular VQA Models: - Gemini 3n - PaliGemma - LLaVA - CogVLM - InstructBLIP - DonutBase - BLIP-2
Word Embeddings
What Are Embeddings?
Definition: Converting words into numerical vectors (arrays of numbers) that capture meaning and relationships.
Why Important: Computers can only process numbers, not words directly.
Types of Embeddings
Static Embeddings
Words have fixed representations regardless of context.
Techniques: - Word2Vec: Learns word associations from large text corpus - GloVe (Global Vectors): Captures global word co-occurrence statistics
Contextual Embeddings
Word representations change based on surrounding context.
Example: - "Bank" in "river bank" vs "bank account" - Contextual embeddings understand these different meanings