Tensors
A tensor is a multi-dimensional array generalizing scalars (0D), vectors (1D), and matrices (2D) to arbitrary rank. Tensors are the core data structure in deep learning frameworks.
What is Tensors?
A tensor is a multi-dimensional array generalizing scalars (0D), vectors (1D), and matrices (2D) to arbitrary rank. Tensors are the core data structure in deep learning frameworks.
A tensor is a multi-dimensional array generalizing scalars (0D), vectors (1D), and matrices (2D) to arbitrary rank. Tensors are the core data structure in deep learning frameworks.
Where is it used?
Every LLM represents tokens, embeddings, attention scores, and weights as tensors. PyTorch tensors flow through transformer layers during both training and inference.
How to build it
In PyTorch, create tensors with `torch.tensor([1,2,3])` or `torch.randn(3,4)`, check their shape with `.shape`, and move them to GPU with `.to('cuda')`.
Code
A practical example: