Course 2-Week 2 Assignment: I surrender!

Hi
I couldn’t figure out how to solve the “initialize_velocity(parameters)” exercise.
I surrender!

Solved by @Ayoub.

Pay attention to the difference between numpy.zeros, which returns an array of a given shape and type, and numpy.zeros_like, which returns an array with the same shape and type as a given array. np.zeros(x.shape, x.dtype) is equivalent to np.zeros_like(x).

Good luck with the rest of the course :slight_smile:

2 Likes

@nramon " np.zeros(x.shape, x.dtype) is equivalent to np.zeros_like(x) ." This is exactly what I thought. In fact, I desperately tried to use “np.zeros” instead of “np.zeros_like” and I think it should work.

1 Like

thank you this is a great trick!

1 Like