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  

2.6 Revisiting the Perceptron Algorithm

Code

What we covered in this video lecture

In this lecture, we took our perceptron implementation from Unit 1 and replaced the Python for loops using PyTorch dot products. This is just the first step in using PyTorch. In later units, we will learn how to use it to its full potential when we implement and train multilayer neural networks.

Additional resources if you want to learn more

We will introduce additional PyTorch features one at a time in the upcoming lectures. So, we recommend you to stay tuned for additional PyTorch resources. If you want to learn more about the perceptron itself, see the resources below:

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

Quiz: 2.6 Revisiting the Perceptron Algorithm

What is the correct way of obtaining a 32-bit floating point tensor b from a NumPy array a?

Correct. This copies a memory view of the NumPy array to a 32-bit float tensor.

Incorrect. The from_numpy() function does not take any arguments besides the input array.

Correct. This creates a copy of the NumPy array as a 32-bit float tensor.

Suppose we have two tensors, a = torch.tensor([1., 2., 3.]) and b = torch.tensor([4., 5., 6.]). And we have implemented the following computation: result = sum([i*j for i, j in zip(a, b)]). We want to make this computation more efficient by replacing the for-loop with built-in PyTorch operation. Which of the following are valid ways to achieve this?

Correct. This replaces the for-loop, which computes a weighted sum, with a dot product.

Correct. This replaces the for-loop, which computes a weighted sum, with a dot product.

Correct. This achieves the same result as the dot-product calls.

Incorrect. This is not a valid operation. Multiplication takes at least two input arguments.

Please answer all questions to proceed.
Watch Video 1

Unit 2.6

Videos
Follow along in a Lightning Studio

DL Fundamentals 2: Tensors and PyTorch

Sebastian
Launch Studio →
Questions or Feedback?

Join the Discussion