function to initialize weights randomly