A network has two layers with no activation function. Layer 1 is h=W1x+b1 with W1=[1201], b1=(1,0)⊤. Layer 2 is y^=W2h+b2 with W2=[2011], b2=(0,1)⊤. What single layer W′x+b′ does the same job, and does it agree with the two layers at x=(1,1)⊤?

Deep learning, Neurons and activations
Level L2 Elementary. Length Medium. Nature Mat Mathematical.

What's being asked

Whether you can show the collapse of stacked affine layers with actual numbers, and say what a non-linearity changes.

Key idea

Substitute layer 1 into layer 2: y^=W2(W1x+b1)+b2=(W2W1) x+(W2b1+b2). So W′=W2W1 and b′=W2b1+b2: depth without a non-linearity gives no extra power.

Steps

  1. This is the harder follow-up to `why-nonlinear-activations`, which comes first. Write the substitution: y^=W2(W1x+b1)+b2=W2W1 x+(W2b1+b2). This is again of the form W′x+b′.
  2. Compute W′=W2W1=[2011][1201]=[2413]. For example, the top-right entry is 2⋅2+0⋅1=4.
  3. Compute b′=W2b1+b2=(2⋅1+0⋅0, 1⋅1+1⋅0)⊤+(0,1)⊤=(2,2)⊤.
  4. Check with x=(1,1)⊤. Two layers: h=(1+2+1, 0+1+0)⊤=(4,1)⊤, then y^=(2⋅4+0, 4+1+1)⊤=(8,6)⊤. One layer: W′x+b′=(2+4+2, 1+3+2)⊤=(8,6)⊤. They agree.
  5. Consequence: the same collapse happens for any number of layers, W′=WL⋯W1. Putting a non-linearity such as ReLU⁡(z)=max⁡(0,z) between the layers breaks this, so depth can then add real power (for example, solving XOR).

Common mistakes

How long your answer should be

Half a page, about 3 minutes.

Read this

Previous in Deep learning: A 4×4 feature map X=[1320421501322611] goes through 2×2 pooling with stride 2, giving a 2×2 output. The gradient of the loss with respect to that output is G=[2−10.54]. What is the gradient with respect to X for max pooling and for average pooling?
Next in Deep learning: A tiny network has input x=(1,2), two hidden units with h1=ReLU⁡(x1+x2−2) and h2=ReLU⁡(−x1+x2−2), and a linear output y^=2h1+3h2+1. Here ReLU⁡(z)=max⁡(0,z). Compute the hidden values, the output y^, and the squared error (y^−y)2 for the target y=5?