import torch
import numpy as np
data = [[1, 2], [3,4]]
tensor = torch.FloatTensor(data)
print(
'\nnumpy: ',np.matmul(data,data),
'\ntorch: ',torch.mm(tensor,tensor)
)
numpy: [[ 7 10]
[15 22]]
torch:
7 10
15 22
[torch.FloatTensor of size 2x2]