Neural Networks and Deep Learning/week2 /

I am getting an error when I run Exercise 8 - L1: L1 = [1.1]
Error: The function should return a float.
1 Tests passed
1 Tests failed

I think my code is correct but cannot figure out why I get this error.

What is the type of your return value? Notice that the error message is telling you that the value should be a scalar float, but it’s not. Hint: what is the purpose of the keepdims = True argument there? It will result in the return value being a numpy array, right? As a debugging technique, you can see the type by adding this print statement:


Also just as a note for the future, we aren’t supposed to publish solution code in the forums or in any other public place. It’s fine to just post the output that you get from a failing test, even if it’s an exception trace that reveals a couple of lines of code. Just not a complete solution (even if it’s incorrect :laughing:). The folks listening to your questions can usually find a helpful response just on the error output. And if not, there are private ways to share code with the mentors. No harm done, since I edited your post to hide the code.

Thanks, Paul, for the hint on keepdims. That fixed the error.