双线性¶
- 类 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])