# chainerx.linear¶

chainerx.linear(x, W, b=None, n_batch_axis=1)

Linear function, or affine transformation.

It accepts two or three arguments: an input minibatch x, a weight matrix W, and optionally a bias vector b. It computes

$Y = xW^\top + b.$
Parameters
• x (ndarray) – Input array, which is a $$(s_1, s_2, ..., s_n)$$-shaped array.

• W (ndarray) – Weight variable of shape $$(M, N)$$, where $$(N = s_{\rm n\_batch\_axes} * ... * s_n)$$.

• b (ndarray) – Bias variable (optional) of shape $$(M,)$$.

• n_batch_axes (int) – The number of batch axes. The default is 1. The input variable is reshaped into ($${\rm n\_batch\_axes} + 1$$)-dimensional tensor. This should be greater than 0.

Returns

Output array with shape of $$(s_1, ..., s_{\rm n\_batch\_axes}, M)$$.

Return type

ndarray

Note

During backpropagation, this function propagates the gradient of the output array to input arrays x, W and b.