torch.einsum
>>> a = torch.arange(60.).reshape(5,3,4)
>>> b = torch.arange(24.).reshape(3,4,2)
>>> o = torch.einsum('fnd,ndh->fh', a, b)
>>> o
tensor([[1012., 1078.],
[2596., 2806.],
[4180., 4534.],
[5764., 6262.],
[7348., 7990.]])
>>>torch.matmul(a[0,:,:].flatten(),b[:,:,0].flatten())
tensor(1012.)
// the first element of the result of einsum
>>> torch.matmul(a[1,:,:].flatten(), b[:,:,0].flatten())
tensor(2596.)
最后
以上就是单身睫毛膏最近收集整理的关于torch.einsum 简单介绍计算流程的全部内容,更多相关torch.einsum内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复