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])