1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Deep Learning with PyTorch

Exercise

Creating tensors from NumPy arrays

Tensors are the fundamental data structure of PyTorch. You can create complex deep learning algorithms by learning how to manipulate them.

The torch package has been imported, and two NumPy arrays have been created, named array_a and array_b. Both arrays have the same dimensions.

Instructions

100 XP
  • Create two tensors, tensor_a and tensor_b, from the NumPy arrays array_a and array_b, respectively.
  • Subtract tensor_b from tensor_a.
  • Perform an element-wise multiplication of tensor_a and tensor_b.
  • Add the resulting tensors from the two previous steps together.