From the course: Hands-On PyTorch Machine Learning
Unlock the full course today
Join today to access over 24,900 courses taught by industry experts.
Understand PyTorch NumPy Bridge
From the course: Hands-On PyTorch Machine Learning
Understand PyTorch NumPy Bridge
- [Instructor] Broadcasting is a way to perform an operation between tensors that have similarities in their shapes. This is an important operation in deep learning. The common example is multiplying a tensor of learning weights by a batch of input tensors, applying the operation to each instance in the batch separately and running a tester of identical shape. Here's an example with two by four multiplying one by four returns a tester of shape two, with dimension of one, with values of two and 16. If you're familiar with broadcasting semantics and NumPy ndarrays, you'll find the same rules apply with PyTorch. The exception to the same shape rule is tensor broadcasting. The rules for broadcastings are, one, each tensors must have at least one dimension, no empty tensors. Comparing the dimension sizes of two tensors, going from last to first, each dimension must be equal or one of the dimensions must be of size one or…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.