Robots Atlas>ROBOTS ATLAS

Neural Networks: From Fundamentals to Modern AI · PyTorch Environment and Tensor Foundations

Tensor: shape, dtype, operations and broadcasting

PyTorch Environment and Tensor Foundations

Introduction

A tensor is the cornerstone of PyTorch — a multidimensional array of numbers living on CPU or GPU, described by shape, dtype and memory layout. This lesson covers tensor creation, basic operations (element-wise, reductions, matrix multiplication), broadcasting rules (right-aligned, dimensions either equal or 1), the difference between .view() and .reshape(), and the memory-contiguity pitfalls after .transpose() / .permute().