Torch sum each row excluding an index ... and sum tensor along rows: b = A.sum(dim = 1,keepdim = True ) # b = torch.tensor([[5], [9]]).
確定! 回上一頁