Building makemore Part 2: MLP

Andrej Karpathy · Beginner ·📐 ML Fundamentals ·3y ago

Key Takeaways

The video demonstrates building a multilayer perceptron (MLP) character-level language model using PyTorch, covering basics of machine learning such as model training, learning rate tuning, hyperparameters, evaluation, and train/dev/test splits.

Original Description

We implement a multilayer perceptron (MLP) character-level language model. In this video we also introduce many basics of machine learning (e.g. model training, learning rate tuning, hyperparameters, evaluation, train/dev/test splits, under/overfitting, etc.). Links: - makemore on github: https://github.com/karpathy/makemore - jupyter notebook I built in this video: https://github.com/karpathy/nn-zero-to-hero/blob/master/lectures/makemore/makemore_part2_mlp.ipynb - collab notebook (new)!!!: https://colab.research.google.com/drive/1YIfmkftLrz6MPTOO9Vwqrop2Q5llHIGK?usp=sharing - Bengio et al. 2003 MLP language model paper (pdf): https://www.jmlr.org/papers/volume3/bengio03a/bengio03a.pdf - my website: https://karpathy.ai - my twitter: https://twitter.com/karpathy - (new) Neural Networks: Zero to Hero series Discord channel: https://discord.gg/3zy8kqD9Cp , for people who'd like to chat more and go beyond youtube comments Useful links: - PyTorch internals ref http://blog.ezyang.com/2019/05/pytorch-internals/ Exercises: - E01: Tune the hyperparameters of the training to beat my best validation loss of 2.2 - E02: I was not careful with the intialization of the network in this video. (1) What is the loss you'd get if the predicted probabilities at initialization were perfectly uniform? What loss do we achieve? (2) Can you tune the initialization to get a starting loss that is much more similar to (1)? - E03: Read the Bengio et al 2003 paper (link above), implement and try any idea from the paper. Did it work? Chapters: 00:00:00 intro 00:01:48 Bengio et al. 2003 (MLP language model) paper walkthrough 00:09:03 (re-)building our training dataset 00:12:19 implementing the embedding lookup table 00:18:35 implementing the hidden layer + internals of torch.Tensor: storage, views 00:29:15 implementing the output layer 00:29:53 implementing the negative log likelihood loss 00:32:17 summary of the full network 00:32:49 introducing F.cross_entropy and why 00:37:56 implementing th
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

This video teaches how to build a multilayer perceptron (MLP) character-level language model using PyTorch, covering the basics of machine learning. It provides a hands-on example of implementing a neural network and training it on a dataset.

Key Takeaways
  1. Implement the embedding lookup table
  2. Implement the hidden layer
  3. Implement the output layer
  4. Implement the negative log likelihood loss
  5. Train the model using PyTorch
  6. Evaluate the model's performance
💡 The video highlights the importance of proper initialization of the network and tuning of hyperparameters to achieve good performance.

Related Reads

📰
I Spent 300+ Hours Learning Machine Learning, Data Science, Deep Learning & MLOps.
Learn how to optimize your machine learning learning journey by focusing on the right topics and avoiding unnecessary ones
Medium · Data Science
📰
Day 4 of My Python Learning Journey: Conditional Statements
Learn to use conditional statements in Python to make decisions based on conditions
Medium · Programming
📰
The Day My Pipeline Promoted 29 Worse Models
Learn from a developer's experience with production bugs in an MLOps system for trading signals and understand the importance of ML engineering
Dev.to · chatoxz
📰
"Why does the AI always leave a few blocks out?"
Discover why AI models often miss a few blocks of data and how to address this issue for better performance
Dev.to · Dexterlung

Chapters (10)

intro
1:48 Bengio et al. 2003 (MLP language model) paper walkthrough
9:03 (re-)building our training dataset
12:19 implementing the embedding lookup table
18:35 implementing the hidden layer + internals of torch.Tensor: storage, views
29:15 implementing the output layer
29:53 implementing the negative log likelihood loss
32:17 summary of the full network
32:49 introducing F.cross_entropy and why
37:56 implementing th
Up next
SQLite3 Tutorial - Learn SQL for Python in 17 Minutes
Thomas Janssen
Watch →