雙線性¶
- 類 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])