Week 3 Programming issue

Hello, I am running into the followin issue:

I am not sure why I am getting this error. Please help!

Compare your code to the examples here:


Thank you so much;
I understand i was missing an additional call to a shape matrix. May I ask why zeros is implemented that way, while randn is not?

1 Like

Hi Abhinav,

It’s great that you understood what was wrong with your code. Double parenthesis is used to invoke a function in python. It passes the tuple (module, item) as a single argument. Otherwise, in its absence, it would pass as separate arguments that would make the process go wrong.

Also, this assignment belongs to DLS course week 3- Planar Data Classification with one hidden layer. I have modified the subject above with the edit pencil :slight_smile:

It’s a good question, but the answer is “because”. Seriously. This is the joy of Open Source Software: there is no guarantee of a unifying conceptual model. The two APIs were implemented by different people at different times with different ideas in mind. As users of the software, we just have to read the documentation and “deal with it”.

Hi Abhinav,

numpy.random.rand and numpy.random.randn are slightly unique “wrap” functions. Please see the link below.
(numpy.random.rand — NumPy v2.0.dev0 Manual)

This is a convenience function for users porting code from Matlab, and wraps random_sample. That function takes a tuple to specify the size of the output, which is consistent with other NumPy functions like numpy.zeros.

So, most of other functions should be consistent as you expected. :slight_smile:

1 Like