How Many Parameters After the Flatten?

Linear Algebra for Deep LearningEasy+10 XP+10

How Many Parameters After the Flatten?

A small image classifier is fed a batch of colour photographs. The batch arrives as a 4-D tensor whose axes are (batch, height, width, channels):

input shape=(32, 10, 10, 3)\text{input shape} = (32,\ 10,\ 10,\ 3)input shape=(32, 10, 10, 3)

The network then runs the pipeline below.

  • The flatten step leaves the batch axis untouched and merges every remaining axis into a single axis of length ddd.
  • Each dense layer computes Z=AW+1bT\mathbf{Z} = \mathbf{A}W + \mathbf{1}\mathbf{b}^{\mathsf{T}}Z=AW+1bT, where WWW has shape (inputs, outputs) and the bias vector b\mathbf{b}b holds one bias per output unit.
StageOutput shape
Input batch(32, 10, 10, 3)(32,\ 10,\ 10,\ 3)(32, 10, 10, 3)
Flatten(32, d)(32,\ d)(32, d)
Dense 1 (with bias)(32, 20)(32,\ 20)(32, 20)
Dense 2 (with bias)(32, 20)(32,\ 20)(32, 20)
Dense 3 (with bias)(32, 4)(32,\ 4)(32, 4)

How many learnable numbers does this network hold in total — every weight and every bias, across all three dense layers?

Your answer is an exact whole number.

Hints

Solve it to unlock the solution

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

parameters