Halloween Sale: **Flat 70% + Addl. 25% Off + 30 Days Extra Lab** on all Courses | Use Coupon **HS25** in Checkout | Offer Expires In

- Home
- Assessment

The weights matrix should be of size (1,12288) so that the transpose matrix of the weights would be of shape (12288,1).

Since the shape of our dataset is (12288,209), it would satisfy the equation `np.dot(w.T,X)`

.

So, let us now aim to initialize our weight matrix with some random numbers and bias vector with 0s.

**Note**:

`np.dot(a,b)`

calculates the dot product of the two vectors a and b.`np.random.seed(0)`

makes sure that the same set of random numbers are generated, no matter how many times the code is run.Using

`np.random.rand`

, we could generate a matrix of any given shape filled with some random numbers ranging in [0, 1).Eg, if we wish to create a 3-dimensional NumPy array containing random numbers and of shape (2,2,2), we could do that by:

`random_3d_array = np.random.rand(2,2,2) print(random_3d_array)`

Create a weight matrix using

`np.random.rand`

to get a matrix of shape`(dim,1)`

, filled with random numbers between 0 and 1.`def initialize_weights(dim): np.random.seed(0) w = << your code comes here >>(dim, 1) b = 0 return w, b`

For example, we could get a 2-dimensional weight matrix and bias vector as follows. Call the

`initialize_weights`

function and store the returned weights and biases in`w`

and`b`

.`dim = 2 w, b = initialize_weights(dim) print("Weights: ",w) print("Biases: ", b)`

XP

Checking Please wait.

Success

Error

No hints are availble for this assesment

Answer is not availble for this assesment

**Note - **Having trouble with the assessment engine? Follow the steps listed
here

## Loading comments...