So as the title says I have a problem with only getting 75/100, even though i am getting passed from all the tests.
I have been searching a bit around on the forums and can see other people have also have experience the same thing, but i have a tried to apply the different / check up on them and it seems like i cant find whatever gives the error.
I have tried to check stride (i am using it in n_H and n_W for both the conv_forward and pool_forward functions) and i am using it in my start variables as well.
I have checked / tired to change the datatype in the conv_single_step to be sure it is a float64.
Have you checked all the expected values in the stride = 2
test case for pool_forward
?
I just checked them all the values match exactly
My Results:
mode = max
A.shape = (2, 2, 2, 3)
A[0] =
[[[1.74481176 0.90159072 1.65980218]
[1.74481176 1.6924546 1.65980218]]
[[1.13162939 1.51981682 2.18557541]
[1.13162939 1.6924546 2.18557541]]]
mode = average
A.shape = (2, 2, 2, 3)
A[1] =
[[[-0.17313416 0.32377198 -0.34317572]
[ 0.02030094 0.14141479 -0.01231585]]
[[ 0.42944926 0.08446996 -0.27290905]
[ 0.15077452 0.28911175 0.00123239]]]
Expected Output:
mode = max
A.shape = (2, 2, 2, 3)
A[0] =
[[[1.74481176 0.90159072 1.65980218]
[1.74481176 1.6924546 1.65980218]]
[[1.13162939 1.51981682 2.18557541]
[1.13162939 1.6924546 2.18557541]]]
mode = average
A.shape = (2, 2, 2, 3)
A[1] =
[[[-0.17313416 0.32377198 -0.34317572]
[ 0.02030094 0.14141479 -0.01231585]]
[[ 0.42944926 0.08446996 -0.27290905]
[ 0.15077452 0.28911175 0.00123239]]]
Ok, that is just one thing that people trip over. The stride logic is the same in pool_forward
as in conv_forward
, but it looks like you got that right already. There are lots of other moving parts of course. Please check your DMs for a message from me about how to proceed.
Just to close the loop on the public thread, Frederik and I had a private conversation about this so that we could have a look at the code. The mistake in this case was in the pool_forward
logic: it is a mistake to use the optional “initial
” argument to np.max
. It is not required in this case and has bad results. To see why, consider the following example:
np.random.seed(42)
A = np.random.randint(1, 10, (3,4)) * -1
print(f"A = {A}")
print(np.max(A))
print(np.max(A, initial=0))
Running that gives this:
A = [[-7 -4 -8 -5]
[-7 -3 -7 -8]
[-5 -4 -8 -8]]
-3
0
So you can see that you get the wrong answer in the case that all the values in a given window of the mask are negative.
Now the unfortunate thing is that the test cases in the notebook don’t happen to catch this error and the grader gives only mysterious feedback not highlighting which function has the error. We might be able to fix the first issue there, but apparently the second one is intractable.
1 Like