liveBook · Manning

What you will learn in Grokking AI Algorithms, Second Edition

by Rishal Hurbans

Chapter by chapter

Chapter 1: Intuition of AI

1.1 What is artificial intelligence? · 1.2 Defining AI · 1.3 Data is the fuel for AI algorithms · 1.4 Algorithms are like recipes · 1.5 Algorithms vs. models · 1.6 The evolution of AI · 1.7 Different types of problems · 1.8 Search problems: Finding a path to a solution · 1.9 Optimization problems: Finding a good solution · 1.10 Prediction and classification problems: Learning from patterns in data · 1.11 Clustering problems: Identifying patterns in data · 1.12 Deterministic models: Getting the same result each time · 1.13 Probabilistic models: Getting potentially different results each time · 1.14 Intuition of AI concepts · 1.15 Narrow intelligence: Specific-purpose solutions · 1.16 General intelligence: Humanlike solutions · 1.17 Super intelligence: The great unknown · 1.18 Old AI and New AI · 1.19 Search algorithms · 1.20 Biology-inspired algorithms · 1.21 Machine learning algorithms · 1.22 Deep learning algorithms · 1.23 Generative models · 1.24 Some uses for AI algorithms · 1.25 Agriculture: Optimizing plant growth · 1.26 Banking: Preventing fraudulent transactions · 1.27 Cybersecurity: Safeguarding email inboxes · 1.28 Health care: Diagnosing patients · 1.29 Logistics: Finding the best delivery route · 1.30 Fitness and health: Optimizing your body · 1.31 Games: Adapting in complexity · 1.32 Conclusion

What you learn in chapter 1 →

Chapter 2: Search fundamentals

2.1 What are planning and searching? · 2.2 Cost of computation: The reason for smart algorithms · 2.3 Problems that search algorithms can solve · 2.4 Representing state: Creating a framework to represent problem spaces and solutions · 2.5 Graphs: Representing search problems and solutions · 2.6 Representing a graph as a concrete data structure · 2.7 Trees: Concrete structures used to represent search solutions · 2.8 Uninformed search: Looking blindly for solutions · 2.9 BFS: Looking wide before looking deep · 2.10 Steps of the BFS algorithm · 2.11 DFS: Looking deep before looking wide · 2.12 Steps of the DFS algorithm · 2.13 Use cases for uninformed search algorithms · 2.14 Optional: More about graph categories · 2.15 Optional: More ways to represent graphs · 2.16 Incidence matrix · 2.17 Adjacency list

What you learn in chapter 2 →

Chapter 3: Intelligent search

3.1 Defining heuristics: Designing educated guesses · 3.2 Informed search: Looking for solutions with guidance · 3.3 A* search · 3.4 Steps in A* search · 3.5 Use cases for informed search algorithms · 3.6 Adversarial search: Looking for solutions in a changing environment · 3.7 Minimax search: Simulate actions and choose the best future · 3.8 Alpha-beta pruning: Optimize by exploring the sensible paths only · 3.9 Use cases for adversarial search algorithms

What you learn in chapter 3 →

Chapter 4: Evolutionary algorithms

4.1 What is evolution? · 4.2 Problems that evolutionary algorithms can solve · 4.3 Life cycle of genetic algorithms · 4.4 Encoding the solution spaces · 4.5 Binary encoding: Representing possible solutions with 0s and 1s · 4.6 Creating a population of solutions · 4.7 Measuring fitness of individuals in a population · 4.8 Selecting parents based on their fitness · 4.9 Using population models · 4.10 Performing roulette-wheel selection · 4.11 Reproducing individuals from parents · 4.12 Single-point crossover: Inheriting one part from each parent · 4.13 Two-point crossover: Inheriting more parts from each parent · 4.14 Uniform crossover: Inheriting many parts from each parent · 4.15 Bit-string mutation for binary encoding · 4.16 Flip-bit mutation for binary encoding · 4.17 Populating the next generation · 4.18 Exploration vs. exploitation · 4.19 Stopping conditions · 4.20 Configuring the parameters of a genetic algorithm · 4.21 Use cases for evolutionary algorithms

What you learn in chapter 4 →

Chapter 5: Advanced evolutionary approaches

5.1 Evolutionary algorithm life cycle · 5.2 Alternative selection strategies · 5.3 Rank selection: Even the playing field · 5.4 Tournament selection: Let them fight · 5.5 Elitism selection: Choose only the best · 5.6 Real-value encoding: Working with real numbers · 5.7 Real-value encoding at its core · 5.8 Arithmetic crossover: Reproduce with math · 5.9 Boundary mutation · 5.10 Arithmetic mutation · 5.11 Order encoding: Working with sequences · 5.12 Importance of the fitness function · 5.13 Order encoding at its core · 5.14 Order mutation · 5.15 Tree encoding: Working with hierarchies · 5.16 Tree encoding at its core · 5.17 Tree crossover: Inheriting portions of a tree · 5.18 Change-node mutation · 5.19 Common types of evolutionary algorithms · 5.20 Genetic programming · 5.21 Evolutionary programming · 5.22 Glossary of evolutionary-algorithm terms · 5.23 More use cases for evolutionary algorithms

What you learn in chapter 5 →

Chapter 6: Swarm intelligence: Ants

6.1 What is swarm intelligence? · 6.2 Problems that ACO algorithms can solve · 6.3 Representing state: What do paths and ants look like? · 6.4 The ACO algorithm life cycle · 6.5 Set up pheromones · 6.6 Set up the population of ants · 6.7 Choose the next visit for each ant · 6.8 Update the pheromone trails · 6.9 Update the best solution · 6.10 Determine the stopping criteria · 6.11 Use cases for ACO algorithms

What you learn in chapter 6 →

Chapter 7: Swarm intelligence: Particles

7.1 What is particle swarm optimization? · 7.2 Optimization problems: A slightly more technical perspective · 7.3 Problems that PSO algorithms can solve · 7.4 Representing state: What do particles look like? · 7.5 PSO algorithm life cycle · 7.6 Set up particles · 7.7 Calculate the fitness particles · 7.8 Update positions of particles · 7.9 Determine the stopping criteria · 7.10 Use cases for PSO algorithms

What you learn in chapter 7 →

Chapter 8: Machine learning

8.1 What is machine learning? · 8.2 Problems that machine learning can solve · 8.3 Supervised learning · 8.4 Unsupervised learning · 8.5 Reinforcement learning · 8.6 Following a machine-learning workflow · 8.7 Collecting and understanding data · 8.8 Preparing data: Clean and wrangle · 8.9 Encoding categorical data · 8.10 Testing and training data · 8.11 Training a model: Predict with linear regression · 8.12 Testing the model: Determine the accuracy of the model · 8.13 Improving accuracy · 8.14 Classification with decision trees · 8.15 Classification problems: This or that · 8.16 The basics of decision trees · 8.17 Training decision trees · 8.18 Classifying examples with decision trees · 8.19 Other popular machine learning algorithms · 8.20 Use cases for machine learning algorithms

What you learn in chapter 8 →

Chapter 9: Artificial neural networks

9.1 What are artificial neural networks? · 9.2 The Perceptron: A representation of a neuron · 9.3 Defining ANNs · 9.4 Forward propagation: Using a trained ANN · 9.5 Backpropagation: Training an ANN · 9.6 Phase A: Setup · 9.7 Phase B: Forward propagation · 9.8 Phase C: Training · 9.9 Python code sample for backpropagation · 9.10 Options for activation functions · 9.11 Designing ANNs · 9.12 Inputs and outputs · 9.13 Hidden layers and nodes · 9.14 Weights · 9.15 Bias · 9.16 Activation functions · 9.17 Cost function · 9.18 Learning rate · 9.19 Expressing ANNs mathematically · 9.20 The weighted sum as a dot product · 9.21 The hidden layer as matrix multiplication · 9.22 Adding the activation function · 9.23 The output layer · 9.24 The final neural network equation · 9.25 The cost function · 9.26 Expressing backpropagation mathematically · 9.27 ANN types and use cases · 9.28 Recurrent neural networks · 9.29 Convolutional neural networks · 9.30 Generative adversarial networks

What you learn in chapter 9 →

Chapter 10: Reinforcement learning

10.1 What is reinforcement learning? · 10.2 The inspiration for reinforcement learning · 10.3 Problems that reinforcement learning can solve · 10.4 The life cycle of reinforcement learning · 10.5 Simulation and data: The agent’s environment · 10.6 Training with the simulation using Q-learning · 10.7 Testing with the simulation and Q-table · 10.8 Measuring the performance of training · 10.9 Model-free and model-based learning · 10.10 Deep learning approaches to reinforcement learning · 10.11 Training with an ANN · 10.12 Use cases for reinforcement learning · 10.13 Robotics · 10.14 Recommendation engines · 10.15 Financial trading · 10.16 Game playing

What you learn in chapter 10 →

Chapter 11: Large language models

11.1 What are LLMs? · 11.2 The intuition behind language prediction · 11.3 Why the sizes of tokens and parameters matter · 11.4 An LLM training workflow · 11.5 Prepare the training data · 11.6 Selecting and collecting data · 11.7 Cleaning and preprocessing data · 11.8 Encoding: From text to numbers · 11.9 Tokenization · 11.10 Vectorization · 11.11 Designing the architecture · 11.12 Encoding: Creating trainable embeddings · 11.13 Sampling a batch of tokens · 11.14 Creating a trainable embedding matrix · 11.15 Creating positional encodings · 11.16 Combining the embedding matrix and positional encodings · 11.17 Self-attention: Start training the LLM · 11.18 Making linear weight matrix projections · 11.19 Asking every other token · 11.20 Calculating attention weights · 11.21 Calculating the weighted sum · 11.22 Using multiple attention heads · 11.23 Normalizing layers · 11.24 Decoding: Finding meaning through neural networks · 11.25 Project up layer · 11.26 Project down layer · 11.27 Layer normalization · 11.28 Stacking Transformer blocks · 11.29 Making a prediction · 11.30 Backpropagation and calculating loss · 11.31 Control the LLM · 11.32 Training epochs · 11.33 Saving checkpoints · 11.34 Stopping mechanisms · 11.35 Hyperparameter tuning · 11.36 Few-shot and zero-shot learning · 11.37 Refining LLMs with reinforcement learning · 11.38 Collecting human-feedback data · 11.39 Training a reward model · 11.40 Fine-tuning the LLM with reinforcement learning · 11.41 LLMs and Mixture of Experts · 11.42 LLMs and retrieval-augmented generation · 11.43 Use cases for LLMs · 11.44 Content generation · 11.45 Information synthesis · 11.46 Coding assistants · 11.47 Enhancement of digital products

What you learn in chapter 11 →

Chapter 12: Generative image models

12.1 What are generative image models? · 12.2 The intuition behind image generation · 12.3 A generative image model training workflow · 12.4 Prepare the image training data · 12.5 Selecting and collecting image data · 12.6 Cleaning and preprocessing image data · 12.7 Embedding: From images to numbers · 12.8 Image normalization · 12.9 Forward diffusion · 12.10 Timestep embedding · 12.11 Text label embedding · 12.12 Design the architecture · 12.13 Convolutional neural networks · 12.14 CNN input shape · 12.15 U-Net · 12.16 Denoise: From numbers to an image · 12.17 Encoder: Downsampling layers · 12.18 Bridge · 12.19 Decoder: Upsampling layers · 12.20 Train: Calculate loss and backpropagation · 12.21 Calculating loss · 12.22 Backpropagation · 12.23 Generating an image · 12.24 Starting with a blank canvas (of pure noise) · 12.25 Denoising the data · 12.26 Controlling the diffusion model · 12.27 Training data composition and diversity · 12.28 Timesteps and noise schedule · 12.29 Attention layers and cross-attention injection · 12.30 Training epochs · 12.31 Inpainting and outpainting · 12.32 Low-rank adaptation · 12.33 High-resolution fixes and upscalers · 12.34 ControlNets and Image Prompt Adapters · 12.35 Refining aesthetics with human feedback · 12.36 Use cases for image generation · 12.37 Creative ideation and concept art · 12.38 Commercial design and advertising · 12.39 Content creation and media · 12.40 Personalization and photo editing

What you learn in chapter 12 →

Concepts explained in this book

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.