pytorch矩阵乘法

torch.mm(mat1, mat2) performs a matrix multiplication of mat1 and mat2

a = torch.randint(0, 5, (2, 3))   # tensor([[3, 3, 2],
                                  #         [2, 2, 2]])
                                  
b = torch.randint(0, 6, (3, 1))   # tensor([[1],
                                  #         [4],
                                  #         [5]])

torch.mm(a, b)   # tensor([[11],
                 #        [17]])

猜你喜欢

转载自www.cnblogs.com/picassooo/p/12810626.html
今日推荐