bilinear_tensor_product

paddle.static.nn. bilinear_tensor_product ( x, y, size, act=None, name=None, param_attr=None, bias_attr=None ) [source]

This layer performs bilinear tensor product on two inputs.

\[out_{i} = x * W_{i} * {y^\mathrm{T}}, i=0,1,...,size-1\]
In this formula:
  • \(x\): the first input contains M elements, shape is [batch_size, M].

  • \(y\): the second input contains N elements, shape is [batch_size, N].

  • \(W_{i}\): the i-th learned weight, shape is [M, N].

  • \(out_{i}\): the i-th element of out, shape is [batch_size, size].

  • \(y^\mathrm{T}\): the transpose of \(y_{2}\).

Parameters
  • x (Tensor) – 2-D input tensor with shape [batch_size, M]. Data type is float32 or float64.

  • y (Tensor) – 2-D input tensor with shape [batch_size, N]. Data type should be same as x.

  • size (int) – The dimension of this layer.

  • act (str|None) – Activation to be applied to the output of this layer. Default None.

  • name (str|None) – For detailed information, please refer to Name . Usually name is no need to set and None by default.

  • param_attr (ParamAttr|None) – To specify the weight parameter attribute. Default: None, which means the default weight parameter property is used. See usage for details in ParamAttr .

  • bias_attr (ParamAttr|None) – To specify the bias parameter attribute. Default: None, which means the default bias parameter property is used. See usage for details in ParamAttr .

Returns

Tensor, A 2-D Tensor of shape [batch_size, size]. Data type is the same as input x.

Examples

>>> import paddle
>>> paddle.enable_static()

>>> x = paddle.static.data("t1", shape=[-1, 5], dtype="float32")
>>> y = paddle.static.data("t2", shape=[-1, 4], dtype="float32")
>>> tensor = paddle.static.nn.bilinear_tensor_product(x, y, size=1000)