chainer.functions.bilinear¶
-
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 e1∈RI⋅J, e2∈RI⋅K, W∈RJ⋅K⋅L, V1∈RJ⋅L, V2∈RK⋅L, and b∈RL, where I is mini-batch size. In this document, we call V1, V2, and b linear parameters.
The output of forward propagation is calculated as
yil=∑jke1ije2ikWjkl+ ∑je1ijV1jl+∑ke2ikV2kl+bl.Note that V1, V2, b are optional. If these are not given, then this function omits the last three terms in the above equation.
Note
This function accepts an input variable
e1
ore2
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.Note
In the original paper, J and K must be equal and the author denotes [V1V2] (concatenation of matrices) by V.
- Parameters
e1 (
Variable
or N-dimensional array) – Left input variable.e2 (
Variable
or N-dimensional array) – Right input variable.W (
Variable
or N-dimensional array) – Quadratic weight variable.V1 (
Variable
or N-dimensional array) – Left coefficient variable.V2 (
Variable
or N-dimensional array) – Right coefficient variable.b (
Variable
or N-dimensional array) – Bias variable.
- Returns
Output variable.
- Return type
- See:
Reasoning With Neural Tensor Networks for Knowledge Base Completion [Socher+, NIPS2013].