Initialize_with zero function 2nd week

hi, anyone plz explain why take dim=2 exactly for weights in,1)

I’m not sure I understand your point. We don’t always take dim = 2, right? The value of dim is the number of features in our particular case. Of course the initialization routine is completely general: it works for any value of dim. It could be 12288 as it is for our “real” image data in this assignment, but it works equally well for 2 or 42 or any other value. Well, the dim value needs to be a positive integer, but that’s the only restriction.

We are writing general code here whenever we can, so that we can reuse it with whatever data we need to. Then when they write test cases for your general routines, they usually use smaller values that you would see with “real” data just to make it easier to check and debug your results.

One other more specific point to make: the syntax you show for invoking np.zeros is incorrect. It takes a single argument of a python “tuple” giving the dimensions that you want.