C4 - [Week 1] pool_forward 1 test failed

Hello !

I correctly implemented a conv_forward and almost done with pool_forwards, however getting a following mistake:

5 Tests passed
1 Tests failed


AssertionError Traceback (most recent call last)
in
14 print(“A[1, 1] =\n”, A[1, 1])
15
—> 16 pool_forward_test(pool_forward)

~/work/release/W1A1/public_tests.py in pool_forward_test(target)
497 ]
498
→ 499 multiple_test(test_cases, target)
500
501 ######################################

~/work/release/W1A1/test_utils.py in multiple_test(test_cases, target)
151 print(’\033[91m’, len(test_cases) - success, " Tests failed")
152 raise AssertionError(
→ 153 “Not all tests were passed for {}. Check your equations and avoid using global variables inside the function.”.format(target.__ name__))

AssertionError: Not all tests were passed for pool_forward. Check your equations and avoid using global variables inside the function.


This seems not informative at all to me, furthermore the output matrix are correct.
Any ideas ?

Many thanks for your support !

Hi Viktoriia,

I am having trouble reproducing that AssertionError. As an exception, maybe you could send me a direct message with your code so that I can have a look what might be the cause of this?

I have a similar problem with 4 tests passed and 2 failed. The error says to avoid using global parameters but I haven’t used any. This attempt was after resetting deadlines and I used the same code which previously passed. Please help

Hello @danxharvey !

The problem I had here was quite stupid. In the block where have an if statement either "max pooling’’ or ‘‘average pooling’’ I did a mistake computing a sum instead of maximum value.
Without looking at your code it is difficult to say anything in case of this error

3 Likes

Hi, thanks for the replying. Turns out to be a bit strange, the notebook wasn’t picking up my use of the channel variable earlier but now it is working fine.

Hy @reinoudbosch , I have the same problem:
Error: Wrong output in AVG-Pool for variable in position 0.
5 Tests passed
1 Tests failed

AssertionError Traceback (most recent call last)
in
14 print(“A[1, 1] =\n”, A[1, 1])
15
—> 16 pool_forward_test(pool_forward)

~/work/release/W1A1/public_tests.py in pool_forward_test(target)
497 ]
498
→ 499 multiple_test(test_cases, target)
500
501 ######################################

~/work/release/W1A1/test_utils.py in multiple_test(test_cases, target)
151 print(’\033[91m’, len(test_cases) - success, " Tests failed")
152 raise AssertionError(
→ 153 “Not all tests were passed for {}. Check your equations and avoid using global variables inside the function.”.format(target.name))

AssertionError: Not all tests were passed for pool_forward. Check your equations and avoid using global variables inside the function.

but I don’t know where the error is. I used the functions np.max and np.average. I appreciate any help.

Hi Bressan,

You can check a number of things:

  • Did you make sure Z is dtype float?
  • Did you loop over the entire batch?
  • Did you implement the stride correctly?

Hi Bressan,

I do not see any errors in the code you provide. A cause could be the way you initialize output matrix A.

That looks correct, so from what you describe I cannot deduce where the problem lies. Maybe you could send me a direct message with your full code so that I can have a look?

I had the same issue.

Fixed it by making sure to slice into channel c when defining a_slice_prev.

Otherwise, the function will take the max or mean of all channels.

1 Like