Bilinear#
- class torch.nn.Bilinear(in1_features, in2_features, out_features, bias=True, device=None, dtype=None)[原始碼]#
對輸入資料應用雙線性變換: .
- 引數
- 形狀
輸入1: 其中 和 表示零個或多個附加維度。輸入的所有維度(除了最後一個)都必須相同。
輸入2: 其中 。
輸出: 其中 和除最後一個維度外的所有維度形狀與輸入相同。
- 變數
weight (torch.Tensor) – 模組的可學習權重,形狀為 。值從 , 其中
bias – 模組的可學習偏置,形狀為 。如果
bias為True,則值從 , 其中
示例
>>> m = nn.Bilinear(20, 30, 40) >>> input1 = torch.randn(128, 20) >>> input2 = torch.randn(128, 30) >>> output = m(input1, input2) >>> print(output.size()) torch.Size([128, 40])