C4 W1 CNN Forward Pass : conv_forward (Dimensions)

Hi @jonaslalin , thank you very much for the help. Ok, I am inching forwards, getting some values for Z but getting an error, below.

Given

A_prev = np.random.randn(2, 5, 7, 4)
W = np.random.randn(3, 3, 4, 8)
b = np.random.randn(1, 1, 1, 8)

Assuming

A_prev = (number of samples, height, width, #channels)
W = (height, width, #channels, #filters)
b = (height, width, #channels, #filters)

Then

1. Loop over samples (2 in the example above)
     2. Loop over rows (horizontally - ie. 5 rows)
         3. Loop over columns (vertically - ie. 7 rows)
             4. Loop over channels (depth -  ie. 4 channels)
                     conv_single_step(foo)

Error

IndexError: index 1 is out of bounds for axis 2 with size 1

Which makes sense, because the volume of the output Z is:

Z.shape -> (2, 1, 1, 8)
m h w c Z
0 0 0 0 1.3062333729376023
0 0 0 1 0.9076977450643843
0 0 0 2 -4.83497864578125
0 0 0 3 -2.5615502864208004
0 0 1 0 IndexError: index 1 is out of bounds for axis 2 with size 1

So it calculates Z for the first 4 channels of the input volume, not of the output volume, then the sliced window tries moving to the next step to the right and does not find it and crashes.

Any pointers would be greatly appreciated!