Course 1 of 9

Python for AI

After this course you can read and run the code of every lesson in the series, and load a pretrained model.

15 lessons, 5 labs and a project. About 1 h 25 min of video.

Start with lesson 1
  1. Notebooks and environmentsA notebook runs your cells on one Python, which remembers only what you ran and imports only what was installed into it.9 min
  2. Your first lines of PythonA variable keeps a value under a name; text and numbers act differently, and a function such as int turns text into a number.4 min
  3. Lists, loops and ifA list keeps values in order; a for loop runs the indented lines under it once for each value, and an if runs its own only when its test is True.5 min
  4. Lab 1Score a chatbot's answersYou will take a chatbot's answers as text, turn them into numbers, and count how many are right with a loop and an if.25 min
  5. Dicts and functionsA dict finds a value by its key; a function does one job when it is called, and a comprehension does it for every item of a list.6 min
  6. Classes, just enoughA class is a plan for objects: each object keeps its own values, and its methods reach them through self.8 min
  7. Lab 2A tiny tokenizerYou will turn a sentence into numbers with a dict and a function, handle a word the vocabulary does not hold, put it all in a class, and turn the numbers back into words.30 min
  8. NumPy arraysA NumPy array is a grid of numbers with a shape, rows first, and you pick from it with one position or one slice for each side.7 min
  9. Vectorization and broadcastingOne line on the whole array replaces a loop, and NumPy repeats a smaller array to fit when the shapes line up on the right.8 min
  10. Lab 3A thousand digits, no loopYou will cut pictures out of a stack of 1,797 handwritten digits, read their shapes, and change every number of every picture in one line, with no loop.30 min
  11. Tables with pandaspandas reads a CSV into a table with named columns; a comparison on a column marks every row True or False, the table keeps the True rows, and groupby gives one number for each group.6 min
  12. Plotting to see dataEach plot answers one kind of question: a histogram shows how values spread, a scatter plot how two values move together, and a line plot how one value changes over steps.4 min
  13. The scikit-learn patternEvery scikit-learn model is an object that learns from a table with fit, then answers with predict; a tool that changes the table learns with fit too, then answers with transform.6 min
  14. Lab 4From a table to a first predictionYou will load a table of 398 real cars, keep the rows you want, sum up each group, draw the plot that answers a question, and teach two models to tell where a car was made.40 min
  15. PyTorch tensors and their shapesA tensor is PyTorch's array, and a layer for pictures reads it as four sides, (batch, channels, height, width), on the CPU or on the GPU.5 min
  16. Calling an APIA program asks an API for data with a request; the answer comes back with a status code and JSON, which Python reads as dicts and lists, and a key that proves who is asking stays outside the code.5 min
  17. From a notebook to a scriptA script is a file of Python that the terminal runs from the first line to the last; it finds the file in the terminal's folder, and it shows a value only when you print it.5 min
  18. Git and GitHubGit keeps every snapshot you commit of a project's folder, and GitHub keeps a copy of them where others can read it, so a file with your key must never be committed.5 min
  19. Lab 5On your own computerYou will set Python up on your own computer, run a script that asks the Hugging Face Hub about a model, turn a stack of pictures into a batch a layer can read, and keep it all in Git with the key's file kept out.45 min
  20. EndingWhat can you build now?That's the whole course. Here's what you can do now, the project where you run a real model yourself, and the labs to start with.1 min
  21. ProjectRun a pretrained model, and check its claimYou build a project that downloads a sentiment model and its test sentences from the Hugging Face Hub, checks the accuracy the model's page claims, and tries the model on reviews you wrote yourself.3 h