bilinear_tensor_product

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

Static Graph

Bilinear Tensor Product Layer

This layer performs bilinear tensor product on two inputs. For example:

\[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 (Variable) – 2-D input tensor with shape [batch_size, M]. Data type is float32 or float64.

  • y (Variable) – 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 api_fluid_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 api_fluid_ParamAttr .

Returns

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

Return type

Variable

Examples

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