Lightning AI Studios: Never set up a local environment again →

Log in or create a free account to track your progress and access additional course materials  

Unit 2 Exercises

Exercise 1: Introducing More PyTorch Functions To Make Your Code More Efficient

The goal of this exercise is to simplify the code implementation of the Perceptron class. For this, we are going to use the torch.where function for the forward method.

Your task is to learn about torch.where using the PyTorch documentation. Finding torch.where in the API documentation is part of this exercise :).

Then, using torch.where, make the appropriate changes in the forward method as instructed in the notebook below.

Link to exercise notebook:


Exercise 2: Make the Perceptron More Efficient Using Matrix Multiplication

In this exercise, you are going to modify the Perceptron class such that it creates the predictions for multiple input examples all at once.

Link to exercise notebook:

Log in or create a free account to access:

  • Quizzes
  • Completion badges
  • Progress tracking
  • Additional downloadable content
  • Additional AI education resources
  • Notifications when new units are released
  • Free cloud computing credits
Watch Video 1

Unit 2 Exercises