A Batch Through Two Layers

Matrix MultiplicationMedium+20 XP+20

A Batch Through Two Layers

When a network processes a whole batch of examples at once, a layer computes

Z=XW+b⃗Z = XW + \vec{b}Z=XW+b

where XXX stores one example per row, WWW holds the layer's weights, and the bias row vector b⃗\vec{b}b is added to every row of XWXWXW.

Here is a batch of two examples, each with three features:

X=[120−132]X = \begin{bmatrix} 1 & 2 & 0 \\ -1 & 3 & 2 \end{bmatrix}X=[1−1​23​02​]

Layer 1 maps 333 features to 222 units:

W1=[2−10314],b⃗1=[1−2]W_1 = \begin{bmatrix} 2 & -1 \\ 0 & 3 \\ 1 & 4 \end{bmatrix}, \qquad \vec{b}_1 = \begin{bmatrix} 1 & -2 \end{bmatrix}W1​=​201​−134​​,b1​=[1​−2​]

Layer 2 takes layer 1's output and maps 222 units to 222 units:

W2=[1−231],b⃗2=[05]W_2 = \begin{bmatrix} 1 & -2 \\ 3 & 1 \end{bmatrix}, \qquad \vec{b}_2 = \begin{bmatrix} 0 & 5 \end{bmatrix}W2​=[13​−21​],b2​=[0​5​]

So the forward pass is

H=XW1+b⃗1,O=HW2+b⃗2H = XW_1 + \vec{b}_1, \qquad O = HW_2 + \vec{b}_2H=XW1​+b1​,O=HW2​+b2​

Report the sum of all four numbers in the final output matrix OOO.

Your answer is a whole number.

Hints

Solve it to unlock the solution

Once you get it right, the reasoning behind the answer shows up here.