bash
import torch
# Define two tensors (matrices)
A = torch.tensor([[1, 2], [3, 4]])
B = torch.tensor([[5, 6], [7, 8]])
# Perform matrix multiplication using @ operator
C = A @ B
print(C)
print(torch.matmul(A,B))
print(torch.mm(A,B))
example2
bash
import torch
import numpy as np
m = 5
p = 3
n = 4
# Define two tensors (matrices)
A = torch.tensor(np.random.randn(m,p))
B = torch.tensor(np.random.randn(p,n))
# Perform matrix multiplication using @ operator
C = A @ B
print(C)
print(torch.matmul(A,B))
print(torch.mm(A,B))
