Parameters and output gradient

Problem

A dense classifier has 44 inputs, 33 hidden units with biases, and 22 softmax outputs with biases. Count the trainable scalars. For h=(1,2,0)h=(1,2,0), p=(0.25,0.75)p=(0.25,0.75), and one-hot y=(1,0)y=(1,0), compute the cross-entropy gradients for the output logits, output bias, and output weight matrix.

Reveal answer or reference solution

The first layer has 3⋅4+3=153\cdot4+3=15 parameters, and the output layer has 2⋅3+2=82\cdot3+2=8, for a total of 2323. Softmax cross-entropy gives

∂L∂z=p−y=(−0.75,0.75),\frac{\partial L}{\partial z}=p-y=(-0.75,0.75),

which is also the bias gradient. The weight gradient is

∂L∂W=(p−y)hT=[−0.75−1.500.751.50].\frac{\partial L}{\partial W}=(p-y)h^{\mathsf T}=\begin{bmatrix}-0.75&-1.5&0\\0.75&1.5&0\end{bmatrix}.
Outcome

Previous attempts

Loading attempts saved in this browser…

    Review Screening Results