Week 1: Convolution model

  1. Can someone explain this snippet of the code?
  2. What does it mean by one output of neuron?
    Also, explain related things to the questions .
    Thank you.

Why are there two lines of code there? It looks like the first one is basically just writing out what the second one does, but the point is you already wrote the conv_single_step function, so why not just call it?

That is the core computation which computes one neuron output of a convolution. If you look carefully at the for loops here in conv_forward, there are 4 loops, right:

For all samples
  for each h value
     for each w value
        for each channel

The key point here is that the h, w and c loops are stepping over every position in the output space, right? You need to generate an output value (neuron value) for each output position.

What happens at that position is that you multiply all the elements of the input with the corresponding filter (f x f x nC_{prev}), add them all up and then you add the bias and the resulting value is a scalar.

1 Like

if we do.

for each w value
     for each h value

will it make any difference?

Each (h, w, c) position has a unique output value. You’ll get the same results if you do the h and w loops in the other order, as long as you are careful to use the right limit values (the inputs don’t have to be square).

1 Like

OKay, Thank you for the clarification. @paulinpaloalto