

def forward(self, inputs):
    e1 = array.as_mat(inputs[0])
    e2 = array.as_mat(inputs[1])
    W = inputs[2]
    xp = cuda.get_array_module(*inputs)
    if (xp is numpy):
        y = numpy.einsum('ij,ik,jkl->il', e1, e2, W)
    else:
        (i_len, j_len) = e1.shape
        k_len = e2.shape[1]
        e1e2 = (e1[:, :, None] * e2[:, None, :])
        e1e2 = e1e2.reshape(i_len, (j_len * k_len))
        W_mat = W.reshape((- 1), W.shape[2])
        y = e1e2.dot(W_mat)
    if (len(inputs) == 6):
        (V1, V2, b) = inputs[3:]
        y += e1.dot(V1)
        y += e2.dot(V2)
        y += b
    return (y,)

dataset/ETHPy150Open pfnet/chainer/chainer/functions/connection/bilinear.py BilinearFunction.forward/original