From the course: Hands-On Introduction to PyTorch for Machine Learning
Unlock this course with a free trial
Join today to access over 24,900 courses taught by industry experts.
Understand PyTorch basic operations - PyTorch Tutorial
From the course: Hands-On Introduction to PyTorch for Machine Learning
Understand PyTorch basic operations
- [Instructor] PyTorch provides a rich set of arithmetic operations for tensors, supporting both element wise and matrix level computations. These operations are similar to NumPy, but with added support for automatic differentiation and GPU acceleration. The very basic operations on tensors are additions, subtractions, multiplications, and divisions. These operations work on tensors of the same shape or broadcastable shapes. We'll explain this a little bit more later. Here's an example for addition and subtraction. We'll first import Torch and NumPy, and we'll create two tensors and print them. Here's the output of the original tensors. Here's the syntax and output of the addition and subtraction. The major categories of operations include common functions such as ab, ceil, floor, clamp, trigonometry functions and their inverses, such as pi, sine, cosine, bitwise operations, comparisons, reductions such as max min,…