bilinear_tensor_product

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

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

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

Return type

Variable

Examples

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