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

Log in or create a free Lightning.ai 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: https://github.com/Lightning-AI/dl-fundamentals/blob/main/unit02-pytorch-tensors/exercises/1_torch-where/exercise_1_torch-where.ipynb

 

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: https://github.com/Lightning-AI/dl-fundamentals/blob/main/unit02-pytorch-tensors/exercises/2_perceptron-matmul/exercise_2_perceptron-matmul.ipynb

Log in or create a free Lightning.ai 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

Videos