torch / nn / torch.nn
Bilinear¶
-
class
torch.nn.
Bilinear
(in1_features: int, in2_features: int, out_features: int, bias: bool = True)[source]¶ Applies a bilinear transformation to the incoming data:
- Parameters
in1_features – size of each first input sample
in2_features – size of each second input sample
out_features – size of each output sample
bias – If set to False, the layer will not learn an additive bias. Default:
True
- Shape:
Input1: where and means any number of additional dimensions. All but the last dimension of the inputs should be the same.
Input2: where .
Output: where and all but the last dimension are the same shape as the input.
- Variables
~Bilinear.weight – the learnable weights of the module of shape . The values are initialized from , where
~Bilinear.bias – the learnable bias of the module of shape . If
bias
isTrue
, the values are initialized from , where
Examples:
>>> 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])
此页内容是否对您有帮助