Hard Parts of AI: Neural Networks

Will Sentance
Codesmith
3 hours, 40 minutes CC
Hard Parts of AI: Neural Networks

Course Description

Understand how AI prediction and neural networks work under the hood! Through hands-on examples such as fraud detection and image recognition, you'll build robust mental models for foundational AI concepts like data preprocessing, probability, training, and prediction. Progress from basic decision models to production-ready neural networks, developing your knowledge and technical communication skills for confidently integrating ML/AI into your applications!

This course and others like it are available as part of our Frontend Masters video subscription.

Preview
Close

Course Details

Published: January 17, 2025

Learn Straight from the Experts Who Shape the Modern Web

Your Path to Senior Developer and Beyond
  • 200+ In-depth courses
  • 18 Learning Paths
  • Industry Leading Experts
  • Live Interactive Workshops

Table of Contents

Introduction

Section Duration: 4 minutes
  • Introduction
    Will Sentance begins the course by explaining how prediction in software engineering changes what developers can build with code. This course explores and builds the full mental models of AI prediction and LLM model development.

ML Decision Making

Section Duration: 1 hour, 11 minutes
  • Refund Request Filtering
    Will explains that predictive systems require sample data. Using an AI system that automates DoorDash refund request as an example, a sample population is identified and potential data points the system can use are established.
  • Creating the Data Converter
    Will creates a "converter" which processes the data points or features from each person to determine if a refund is approved or denied. The conditions or boundaries within the converter and crafted from the observed examples in the current population.
  • Applying the Data Converter
    Will verifies the logic within the converter using the sample data. The converter is then used to predict the refund result with a new, fraudulent example. The result is a refund which leads to a discussion on how the decision model needs to be updated.
  • Boundaries in a Decision Model
    Will explains the term for the converter is a "model". This model represents a decision tree in which a computer would evaluate each condition to reach a prediction. The process of Machine Learning and AI is then generalized to include tools for finding the best model, minimizing the effort it takes the model to reach a prediction, and ensuring the sample reflects the overall population.
  • Challenges in Creating a Production Model
    Will summarizes the fraud prediction model and highlights the challenges of moving the model into a production environment. These challenges include training it on a larger data set, end-to-end deployment strategies, and ongoing model performance measurements.

Training a Neural Network

Section Duration: 1 hour, 57 minutes
  • Neural Network Data
    Will introduces the next prediction challenge: a model that can detect a smile in an image. The scope is simplified by constraining the size of the images to a three-by-four-pixel grid. Ones and zeros are used to reflect active pixels, and sample smiles/non-smiles are provided.
  • Training a Pixel Data Model
    Will builds a pixel detection model based on the sample data. The model is trained on two samples, one smile and one non-smile. A matrix of multipliers is built to convert the pixel data into the correct output value. This system represents the foundations of a neural network.
  • Inferring Using the Pixel Data Model
    Will uses an unknown smile to test the neural network's ability to detect a smile. The resulting value is correct, which means the model was correctly trained on the sample dataset.
  • Validating Pixel Data Neural Network
    Will adds an additional sample to the population to revalidate the neural network's accuracy. The results are incorrect, leading to the conclusion that "weights" are required to ensure the model understands which pixels are relevant to the conversion and their relative importance.
  • Learning Multipliers with Larger Sample
    Will computes how each multiplier in the system should be adjusted to achieve the best overall result. It's determined that some multipliers should be higher while others should be lower.
  • Applying All Weight Changes
    Will applies all the multiplier changes at once. A new round of testing is performed to evaluate the accuracy of the updated model. The results achieve a score of 3 out of 4, however, the 4th example is much less accurate that the previous iteration.
  • Improve Accuracy of Model
    Will summarizes why applying all the individual improvements at once leads to better accuracy in the overall system. However, continued tweaking is required to get closer to 100% accuracy. Steady adjustments to a model like this are the foundations of machine learning.
  • Sigmoid Function
    Will introduces the sigmoid function, which "squashes" values into percentages that better reflect the overall confidence of the system's prediction. Rather than evaluating a target value for each prediction from the model, percentages generated from the sigmoid function better categorize samples with a wider distribution.
  • Applying Gradient Descent
    Will applies the Sigmoid function to the results and introduces gradient descent, making smaller and smaller adjustments to the weights to improve conversion accuracy. While there is no perfect target result, a Sigmoid of 2 (or 90%) is a typical goal.
  • Validating Weight Accuracy
    Will updates the model weights to reflect 100 iterations for gradient descent. A new smile image is added to the sample and used to validate the current state of the model. The weights achieve a 93% success rate and 7% error rate.
  • Preprocessing Sample Data
    Will explains the need to preprocess images before model training. This allows the model to focus on its intended goal. Additional models may be required for the reprocessing stage to adjust the rotation of images or determine if there's a face.

Neural Networks in Production

Section Duration: 20 minutes
  • Developing a Production Model
    Will discusses the process and challenges of getting a model into production. Creating a more robust neural network design with increased layers and a refined evaluation framework helps prepare the model. Once in production, the model must be scaled across GPU, provide an API, and include periodic monitoring and retraining.
  • Combining Models
    Will explains how models can be combined to produce content. An image detection model can evaluate results produced from an image generation model, allowing the two models to be combined to achieve accurate image generation through diffusion.
  • Extending the Principles of Machine Learning
    Will summarizes the key components of building a neural network and extends those principles into further scaling these models beyond what's imaginable. However, at their core, the success of any model depends on its ability to generalize and capture patterns from a sample population and assume that population is representative of the larger world

Wrapping Up

Section Duration: 6 minutes

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Start a 7-Day Free Trial