In machine learning (ML), a tensor is a generalization of scalars, vectors, and matrices to higher dimensions and is a core data structure used to represent and process data.
Formal Definition:
A tensor is a multidimensional array of numerical values. Its rank (or order) denotes the number of dimensions:
Why Tensors Matter in ML:
Example in Code (PyTorch):
import torch
# 2D tensor (matrix)
x = torch.tensor(\[[1.0, 2.0], \[3.0, 4.0]])
print(x.shape) # torch.Size(\[2, 2])
In summary, a tensor is the fundamental building block for data in machine learning frameworks, offering a consistent and optimized structure for mathematical operations.