Week 3 Random assigned seed returning different values

Hello in my jupyter notebook my values differ from the assertion ones in turn breaking all that follows.

Welcome @roscar! Please, refrain from showing your programming work in the Discourse forum, as much as it can be avoided.

First, it is important that you not reset the random seeds in the notebooks. I see that you have not. Good! Make sure that the distribution that you are drawing from is correct. It should be the standard Normal–not the uniform.


I got it thanks, apologies for the solution

Note that you can edit your own posts. If you wanted to do a community service, you could go back and remove the solution code from your post. It’s not that big a deal for something that’s just a couple of lines, but we’re all learning how to use this new Discourse platform so I thought it was worth mentioning. The notion of editing posts is useful in general. At least I find that I almost always can think of a better way to say something after I read what I just typed :nerd_face:

For some reason I am unable to edit the OP.

Notice the lack of the pencil (edit)

Sorry, I’m not sure why you get no “edit pencil” in that case. We are all learning how Discourse works. I am able to edit my own posts, but not anyone else’s.

Hi @kenb, where was it discussed in the course notes that we need to use standard Normal? In the video on Random Initialisation it uses np.random.rand rather than the one you suggested (which now makes my code work). How are we supposed to know to use standard Normal?

@Marina: At about 4:05 in the lecture in Week 3 on Random Initialization, Prof Andrew explicitly writes out:


If you read the numpy random documentation, you’ll see that is the Normal Distribution with mean of 0 and standard deviation of 1. At that point in the video, he also mentions that this is a Gaussian Distribution, which is just a slightly geekier way to say Normal Distribution.

Then if you read the instructions in the notebook, they literally write out the correct code for you using np.random.randn. All you have to do is fill in the dimensions.

@paulinpaloalto I have found my error. I had incorrectly copied the code from the video and had used np.random.rand rather than np.random.randn which provides a very different result.