chainer.functions.bilinear(e1, e2, W, V1=None, V2=None, b=None)[source]

Applies a bilinear function based on given parameters.

This is a building block of Neural Tensor Network (see the reference paper below). It takes two input variables and one or four parameters, and outputs one variable.

To be precise, denote six input arrays mathematically by \(e^1\in \mathbb{R}^{I\cdot J}\), \(e^2\in \mathbb{R}^{I\cdot K}\), \(W\in \mathbb{R}^{J \cdot K \cdot L}\), \(V^1\in \mathbb{R}^{J \cdot L}\), \(V^2\in \mathbb{R}^{K \cdot L}\), and \(b\in \mathbb{R}^{L}\), where \(I\) is mini-batch size. In this document, we call \(V^1\), \(V^2\), and \(b\) linear parameters.

The output of forward propagation is calculated as

\[y_{il} = \sum_{jk} e^1_{ij} e^2_{ik} W_{jkl} + \ \sum_{j} e^1_{ij} V^1_{jl} + \sum_{k} e^2_{ik} V^2_{kl} + b_{l}.\]

Note that V1, V2, b are optional. If these are not given, then this function omits the last three terms in the above equation.


This function accepts an input variable e1 or e2 of a non-matrix array. In this case, the leading dimension is treated as the batch dimension, and the other dimensions are reduced to one dimension.


In the original paper, \(J\) and \(K\) must be equal and the author denotes \([V^1 V^2]\) (concatenation of matrices) by \(V\).

  • e1 (Variable) – Left input variable.
  • e2 (Variable) – Right input variable.
  • W (Variable) – Quadratic weight variable.
  • V1 (Variable) – Left coefficient variable.
  • V2 (Variable) – Right coefficient variable.
  • b (Variable) – Bias variable.

Output variable.

Return type:


Reasoning With Neural Tensor Networks for Knowledge Base Completion [Socher+, NIPS2013].