Bilinear#
- class torch.nn.modules.linear.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])