发现
对于torch.matmul和torch.bmm,都能实现对于batch的矩阵乘法:
a = torch.rand((2,3,10))
b = torch.rand((2,2,10))
### matmal()
res1 = torch.matmul(a,b.transpose(1,2))
print res1
"""
...
[torch.FloatTensor of size 2x3x2]
"""
### bmm()
res2 = torch.bmm(a,b.transpose(1,2))
print res2
"""
...
[torch.FloatTensor of size 2x3x2]
"""