PyTorch is an optimized tensor library for deep learning using GPUs and CPUs.

She is much faster than NumPy with similar functionality. NumPy array and PyTorch tensor are both multidimensional table of data, with all items of the same type.

import torch
data = [[1,2,3],[4,5,6]]
tns = torch.tensor(data)
tns
tensor([[1, 2, 3],
        [4, 5, 6]])
tns[1]
tensor([4, 5, 6])
tns[:,1]
tensor([2, 5])
tns[1,1:3]
tensor([5, 6])
tns+1
tensor([[2, 3, 4],
        [5, 6, 7]])
tns.type()
'torch.LongTensor'
tns*1.5
tensor([[1.5000, 3.0000, 4.5000],
        [6.0000, 7.5000, 9.0000]])
torch.tensor([1,2,3]) + torch.tensor([1,1,1])
tensor([2, 3, 4])
torch.tensor([0]) + torch.tensor([1,1,1])
tensor([1, 1, 1])