torch.addbmm#
- torch.addbmm(input, batch1, batch2, *, beta=1, alpha=1, out=None) Tensor#
執行儲存在
batch1和batch2中的矩陣的批次矩陣-矩陣乘積,並進行規約相加(所有矩陣乘法沿第一個維度累加)。input將被加到最終結果中。batch1和batch2必須是 3D 張量,每個張量包含相同數量的矩陣。如果
batch1是一個 張量,batch2是一個 張量,input必須 與 張量進行廣播,並且out將是一個 張量。如果
beta為 0,則input的內容將被忽略,並且其中的 nan 和 inf 不會被傳播。對於 FloatTensor 或 DoubleTensor 型別的輸入,引數
beta和alpha必須是實數,否則它們應該是整數。此運算子支援TensorFloat32。
在某些 ROCm 裝置上,當使用 float16 輸入時,此模組將對反向傳播使用不同精度。
- 引數
- 關鍵字引數
beta (Number, optional) –
input的乘數()alpha (Number, optional) – batch1 @ batch2 的乘數()
out (Tensor, optional) – 輸出張量。
示例
>>> M = torch.randn(3, 5) >>> batch1 = torch.randn(10, 3, 4) >>> batch2 = torch.randn(10, 4, 5) >>> torch.addbmm(M, batch1, batch2) tensor([[ 6.6311, 0.0503, 6.9768, -12.0362, -2.1653], [ -4.8185, -1.4255, -6.6760, 8.9453, 2.5743], [ -3.8202, 4.3691, 1.0943, -1.1109, 5.4730]])