juniorPyTorch

What is a tensor in PyTorch?

Updated May 17, 2026

Short answer

A tensor is the core data structure in PyTorch, similar to NumPy arrays but with GPU support and autograd capabilities.

Deep explanation

Tensors are multi-dimensional arrays that support automatic differentiation. They are the foundation of all PyTorch computations and can be moved between CPU and GPU seamlessly.

Real-world example

Used to represent images, text embeddings, and model parameters in deep learning models.

Common mistakes

  • Confusing tensors with Python lists or forgetting requires_grad for training variables.

Follow-up questions

  • What is tensor broadcasting?
  • How are tensors stored in memory?

More PyTorch interview questions

View all →