数学运算:
a = torch.tensor([[1, 2, 3], [4, 5, 6]])
b = torch.tensor([[7, 8, 9], [10, 11, 12]])
tensor([[1, 2, 3],
[4, 5, 6]])
tensor([[ 7, 8, 9],
[10, 11, 12]])
torch.add(tensor1, tensor2): 张量相加。
result = torch.add(a, b)
tensor([[ 8, 10, 12],
[14, 16, 18]])
torch.sub(tensor1, tensor2): 张量相减。torch.mul(tensor1, tensor2): 张量相乘。
torch.mul(a,b)
tensor([[ 7, 16, 27],
[40, 55, 72]])
torch.div(tensor1, tensor2): 张量相除
浙公网安备 33010602011771号