What is the meaning of these lines and why are we writing -1 at the end

10*(2*np.random.random((x.shape[1],))-1)

why are we mutiplying it by 2 and subtracting -1 at the end.

Hey @sankalparora5, let me explain you that :

np.random.random() is used to generate a value between [0,1)

Multiplying by 2 makes the range to be between [0,2).
Now , since we want negative values also, we have subtracted -1 from np.random.random( ). So we will now get values between [-1,1).
Multiplying by 10 outside will make the final range as [-10,10).

This was our final goal right ?

I hope this explanation helps you :slight_smile:
Happy Learning :slight_smile:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.