Skip to content

a small neural network

learning

Level 3 of 3

Also called a multilayer perceptron and learning by back propagation.

test yourself

Six questions, four to pick from and two for paper. Three numbers such as 3; 4; 20 are the hidden units, the step size and the passes. Each answer stays hidden until you open it.

fresh numbers: the questions a run answers, asked again on new numbers

choose one

question 1

A network with 3 hidden units makes 20 passes. How many weights does it nudge in all?

00.20.40.60.8100.20.40.60.81xy1h1h2h31o
the answer, and why

the answer is B

Each pass nudges 3 × 3 + 3 + 1 = 13 weights, the 9 into the hidden units, the 3 out of them and the output's bias. 13 × 20 = 260.

if you chose another

  • That counts the hidden units each pass, not the weights.
  • That is one pass.
  • That counts the corners fed, 4 a pass.

question 2

The starting network with 2 hidden units gives the corners 0 0, 0 1, 1 0 and 1 1 the outputs 0.456, 0.449, 0.432 and 0.426. Their answers are 0, 1, 1 and 0. What is the loss, to the thousandth?

the answer, and why

the answer is D

The misses are 0.456 − 0 = 0.456, 1 − 0.449 = 0.551, 1 − 0.432 = 0.568 and 0.426 − 0 = 0.426. Squared, about 0.208, 0.304, 0.323 and 0.181, which add to 1.016. Their average over the 4 corners, 1.016 ÷ 4, is about 0.254.

this tests how it works, on the learn page

if you chose another

  • That is the average output, not a miss.
  • That is the squares added, not their average.
  • That is the misses averaged without squaring them.

question 3

Which change makes each pass nudge more weights?

the answer, and why

the answer is B

A pass nudges 4 weights for each hidden unit and 1 more. Only the hidden units change that.

this tests best, worst and average, on the learn page

if you chose another

  • The step size changes how far each weight moves, not how many move.
  • More passes nudge more in all, but the same number each pass.
  • Every weight is nudged once a pass, whatever it starts at.

question 4

Two hidden units, step size 8, 50 passes. How many corners are fed in all?

00.20.40.60.8100.20.40.60.81xy1h1h21o
the answer, and why

the answer is D

Each pass feeds the 4 corners forward once. 4 × 50 = 200.

if you chose another

  • That is the weights nudged, 9 × 50.
  • That is the passes.
  • That is one pass.

pen and paper

question 5about 8 minutes

The watch page's first run, 3 hidden units, after its 150 passes. Worked from the weights it draws, each to the tenth, at the corner 1 1 the hidden units give 0.909, 0.142 and 0.450. Their weights to the output are −3.8, 3.8 and −0.3, and the output's bias is 1.9.

  1. Multiply each hidden value by its weight to the output.
  2. Which hidden unit pushes the output hardest, and towards which shape?
  3. Add the three and the bias, squash the sum (−1.149 gives 0.241), and say whether the corner is right.
a hint

Above 0 pushes towards square, below 0 towards triangle; the product furthest from 0 pushes hardest.

a worked answer

0.909 × −3.8 = −3.454; 0.142 × 3.8 = 0.540; 0.450 × −0.3 = −0.135. Hidden 1, whose −3.454 is furthest from 0, pushes hardest, towards triangle. The sum is 1.9 − 3.454 + 0.540 − 0.135 = −1.149, squashed 0.241. That is under 0.5, so triangle, which is right: at 1 1 across and up agree.

this tests how it works, on the learn page

what a full answer includes
  • The three products.
  • Hidden 1, towards triangle.
  • About 0.241, triangle, right.

question 6about 8 minutes

A network with 4 hidden units makes nn passes.

  1. Count the weights one pass nudges, naming each kind.
  2. Write the nudges for nn passes, and say how they grow.
  3. Count them for 10 passes, and for 2 hidden units and 10 passes.
a hint

Each hidden unit has weights in and a weight out; the output has one more number of its own.

a worked answer

Each hidden unit has 3 weights in, from across, from up and its bias: 12. Then 4 weights to the output and the output's bias: 17 a pass. So 17n17n in nn passes, a fixed multiple of nn, so Θ(n)\Theta(n). For 10 passes, 170. With 2 hidden units, 9 a pass: 90.

Why do 4 hidden units nudge 17n17n weights in nn passes?
  1. the move: count one pass

    the line:
    N=(3×4+4+1)n\begin{gathered} N = (3 \times 4 \\ + 4 + 1)n \end{gathered}
    weightshow many
    into the hidden units, 3 each12
    from the hidden units to the output4
    the output's bias1
    a pass17
    The 17 lines of the network with 4 hidden units, as the watch page draws them. Each is nudged once a pass.

    why it is allowed: NN is the weights nudged. Each of the 4 hidden units has 3 weights in, from across, from up and its bias, and 1 out to the output. The output has its bias. A pass nudges each once, and there are nn passes.

  2. the move: work out the bracket

    the line:
    N=17nN = 17n

    why it is allowed: By line 1, 3 × 4 = 12, and 12 + 4 + 1 = 17. For 10 passes, 170.

  3. the move: a ceiling

    the line:
    N≤17nN \le 17n

    why it is allowed: By line 2, NN is exactly 17n17n, so never above it.

  4. the move: read it as a bound

    the line:
    N∈O(n)N \in O(n)

    why it is allowed: By line 3, NN is at most 17 times nn, a fixed number times nn, which is what O(n)O(n) says.

  5. the move: a floor

    the line:
    N≥17nN \ge 17n

    why it is allowed: By line 2 again, never below it either.

  6. the move: read it as a bound

    the line:
    N∈Ω(n)N \in \Omega(n)

    why it is allowed: By line 5, NN never drops below 17 times nn, which is what Ω(n)\Omega(n) says.

  7. the move: ceiling and floor together

    the line:
    N∈Θ(n)N \in \Theta(n)

    why it is allowed: Lines 4 and 6 bound NN by the same growth, nn.

try it with a small nn: at n=10n = 10, line 1 gives N=170N = 170, which you can work out by hand

this tests where the formula comes from, on the learn page

what a full answer includes
  • Seventeen, with its three kinds.
  • Seventeen n, Theta of n.
  • One hundred and seventy, and ninety.