Backend 3
PyTorch
PyTorch is a tensor library commonly used for machine learning and GPU-backed research code.
When to use PyTorch
Use the official PyTorch site when you need installation notes, documentation, or ecosystem information.
Official PyTorch siteUse PyTorch when your workflow involves neural networks, tensor operations on a GPU, or model training loops.
It can also be useful for numerical experiments that benefit from tensors and automatic differentiation.
Minimal example
import torch
x = torch.tensor([0.0, 1.0, 2.0])
y = x ** 2
print(y)
Working habit
Check where tensors live before mixing CPU and GPU code. Device mismatches are a common source of early errors.
print(x.device)