C1_W2_Assignment Exercise 6

The exercise starts with:

def ref_to_diagonal(A_ref):
### START CODE HERE ###
# multiply row 3 of the matrix A_ref by -3 and add it to the row 2
A_diag = None

But A_diag is not assigned to anything initially.
Is it okay to copy A_ref to A_diag first and then then perform the rest of the operations?

Regards,
Amit

Hello @Amit_Agarwal1 and welcome to the DeepLearning.AI community,
From what you have given here, I think you’re supposed to assign A_diag the solution that you will get after multiplying row 3 of the matrix A_ref by -3 and add it to the row 2

multiply row 3 of the matrix A_ref by -3 and add it to the row 2

This will result in a 1x4 array.

and then we are supposed to

multiply row 3 of the new matrix A_diag by -3 and add it to the row 1

the new A_diag does not have row 3. it has just 1 row.

I managed to do it. You need to first assign A_diag a copy of A_ref and then continue. Thanks for your help.

1 Like