Hi Paul.
I have:
retrieved the 4 dimensions from the input shape
retrieved the 2 hyperparameters from the hparameters dictionary
defined n_H, n_W and n_C as per the Exercise 4 instructions
initialised the 4 dimensions of A
looped through the training examples (the first dimension)
looped through the vertical axis of the output volume (the second dimension), factoring in the stride and adding f to define the end coordinate
looped through the horizontal axis of the output volume (the third dimension), factoring in the stride and adding f to define the end coordinate
looped over the channels of the output volume (the fourth dimension)
defined the current slice on the ith training example of A_prev using a term for “everything”, for the vertical start and end, for the horizontal start and end, and for channel c as given in the instructions.
the code supplied for case 1 gives:
A_prev = np.random.randn(2, 5, 5, 3) which correspond to the 4 dimensions
hparameters = {“stride” : 1, “f”: 3}
a slice with a “f” of 3 has 3 positions in the vertical if there is a “stride” of 1
it also has 3 positions in the horizontal
2 training examples x 3 vertical positions x 3 horizontal positions x 3 channels =
54 values for I in the range (m)
if I then print A.shape I get 54 rows of A.shape: (2, 3, 3, 3) – these are in a slider window and I know of no way to confirm there are 54, but this would seem logical.
these are followed by:
mode = max
A.shape = (2, 3, 3, 3)
A[1, 1] =
[[1.96710175 0.90159072 2.10025514]
[1.96710175 0.90159072 1.65980218]
[1.62765075 1.6924546 1.65980218]]
the first three (vertical) values are correct
this is followed by another 54 rows of A.shape: (2, 3, 3, 3), followed by:
mode = average
A.shape = (2, 3, 3, 3)
A[1, 1] =
[[ 0.03158753 0.0066912 -0.06992018]
[ 0.27774273 -0.10450644 -0.07378899]
[ 0.07921582 0.16487069 0.06209026]]
This is followed by (I am guessing) 162 further rows of A.shape, but now the shape changes periodically
The 54 values for I in the range that I have defined are the right shape. I do not know what the later “162” rows are referring to.
There do not seem to be many parameters to adjust. If I remove the “stride” from the vertical and horizontal looping, the A[1, 1] numbers change, as expected. These seem to be the only lines of code that influence the A[1, 1], but, with “stride” factored in, they seem to be correct.
Am I missing something?