pytorch中的乘法有 * ,torch.mul,torch.mm,torch.matmul,torch.bmm。其中*乘和torch.mul都是element-wise的乘法,也就对应元素相乘。而后两种是数学上的矩阵乘法。

torch.mm只能计算二维矩阵的乘法,其他维度的要用torch.matmul,
torch.bmm是batch mm的缩写,计算batch的二维矩阵乘法,
torch.matmul可以计算batch的二维矩阵且可以广播。
参考链接:https://blog.csdn.net/real_ilin/article/details/112412137
https://blog.csdn.net/McEason/article/details/104182648
pytorch学习笔记——算术运算
于 2022-03-27 21:50:21 首次发布
763

被折叠的 条评论
为什么被折叠?



