Reason for initialization of an np.zeros() array instead of an emtpy array

Is there a specific reason for initialization of a numpy array with zeros of a given size, without just declaring an empty array using np.array() ? Does it take up less memory? (An example of this is in the calculation of the gradient dj_dw in the compute gradient function.)

Typically this is done in the notebooks so the function will return the correct size argument even if the student adds no code.

1 Like