Bilinear¶
- class torch.nn.Bilinear(in1_features, in2_features, out_features, bias=True, device=None, dtype=None)[source][source]¶
对输入数据应用双线性变换: 。
- 参数
- 形状
Input1: 其中 且 表示任意数量的附加维度,包括无。除了输入的最后一个维度外,所有维度都应相同。
Input2: 其中 。
Output: 其中 且除了最后一个维度外,所有维度都与输入形状相同。
- 变量
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])