1. Home
  2. Explore
  3. Computer Science
  4. Convolutional Neural Networks

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Convolutional Neural Networks

Speaker 1Speaker 2

Convolutional Neural Networks

5:14
0:00-5:14
  1. Simon

    So Anna, we're starting this course with a simple question: is this a hot dog? And it turns out that training a computer to answer that question is a perfect way to learn about convolutional neural networks.

  2. Anna

    Exactly. CNNs are the secret sauce behind image classification. But before we dive into those, the instructor, Kylie Ying, walks through the fundamentals of machine learning first. That's smart—you need the building blocks.

  3. Simon

    Right. She kicks off with the big picture: machine learning is a subdomain of computer science where algorithms learn from data without being explicitly programmed. And there are three major types: supervised, unsupervised, and reinforcement learning.

  4. Anna

    Supervised learning uses labeled inputs—like pictures of cats and dogs with labels attached. The computer learns from those examples. Unsupervised learning has no labels; the model finds patterns on its own. And reinforcement learning is like training a dog with treats—the agent learns from rewards and penalties.

  5. Simon

    Our hot dog project is supervised learning. So we focus on that. In supervised learning, each input is a feature vector—basically a list of numbers. Those features can be qualitative, like categories, or quantitative, like numerical values. And the output can be either a discrete class (classification) or a continuous value (regression).

  6. Anna

    For hot dogs, it's binary classification: hot dog or not hot dog. And the features come from the image pixels. But we also need to split our data into training, validation, and test sets. The training set teaches the model, the validation set helps you pick the best model—like a test drive—and the test set gives a final unbiased performance check.

  7. Simon

    And to measure how well the model is doing, we use a loss function. For regression it might be L1 or L2 loss; for binary classification it's binary cross-entropy. The loss tells us how far off our predictions are. The goal is to minimize that loss.

  8. Anna

    Now, the model itself is a neural network. It starts with an input layer of features, then hidden layers of neurons, and finally an output layer. Each neuron does a weighted sum of its inputs, adds a bias, and passes that through an activation function like ReLU or sigmoid. That nonlinearity is crucial—without it, the whole network would collapse into a linear model.

  9. Simon

    Training the network means adjusting the weights using something called gradient descent. You compute the gradient of the loss with respect to each weight, then take a small step in the direction that reduces the loss. The step size is the learning rate. This process is backpropagation.

  10. Anna

    Okay, so that's the standard neural network. But images are tricky—they're 2D arrays of pixel values. Feeding a whole image into a regular neural network would mean flattening it into a huge vector, losing spatial information. That's where CNNs come in.

  11. Simon

    CNNs add convolutional and pooling layers before the fully connected layers. The convolution layer slides a small filter (or kernel) over the image, performing element-wise multiplication and summing to produce a feature map. These filters learn to detect edges, textures, and more complex patterns as you go deeper.

  12. Anna

    Then pooling reduces the size of the feature maps—max pooling takes the largest value in each window, average pooling takes the average. This downsamples the data while keeping the most important information. After several conv+pool blocks, you flatten the result and feed it into a regular neural network for classification.

  13. Simon

    Kylie actually shows a cool interactive visualization where you draw a digit, and you can see how each convolution and pooling layer transforms it. It really drives home that the network is learning a hierarchy of features.

  14. Anna

    Then she jumps into a real implementation using TensorFlow and the Food101 dataset. The goal is to classify images as hot dog or not hot dog. First, she resizes all images to 128x128 and relabels them: 1 for hot dog, 0 for anything else.

  15. Simon

    Because the dataset has only 750 hot dog images but thousands of non-hot dogs, she balances the classes by up-sampling the hot dogs and using a 50-50 sample from both classes. She also sets up a data pipeline with caching, batching, and prefetching for efficiency.

  16. Anna

    Then she builds the CNN model: a sequential model with rescaling (dividing pixels by 255), a few Conv2D layers with ReLU activation and max pooling, then flatten, then dense layers. The output is a single neuron with no activation—using binary cross-entropy loss from logits.

  17. Simon

    She trains for 50 epochs and sees the training accuracy hit 100%, but the validation accuracy peaks around 73% and then declines. That's overfitting—the model memorized the training data but doesn't generalize well.

  18. Anna

    To fix that, she adds dropout layers (randomly turning off 25% of connections) and data augmentation—random flips and rotations. She also adds kernel regularizers to penalize large weight changes. After those changes, the validation accuracy stabilizes around 70%.

  19. Simon

    And in the end, she tests on nine validation images and the model correctly classifies every one—hot dogs like that sausage and waffle, and non-hot dogs like hummus. So the model works, even if it's not perfect.

  20. Anna

    That's the whole journey: from the basics of ML, through neural networks, to CNNs, and finally a practical project. Now we can look at an image and say, 'Is this a hot dog?' and have a good idea how the computer makes that call.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent