Learn Before
Code

torch.tensor()

The torch.tensor() function in PyTorch constructs a tensor from data such as a Python list or a NumPy array. When preparing datasets for neural networks, this function is used to load numerical features and target labels into PyTorch's native multidimensional array format.

0

1

Updated 2026-05-01

Contributors are:

Who are from:

Tags

D2L

Dive into Deep Learning @ D2L