Final Course 2 Week 1 Exam Calculation

Hello all,

I’ve been working on Course 2 Week 1 exam, I have successfully done the first two graded cells but I am stuck on 3. Since the math and code are somewhat complicated and I am not yet officially trained in Python, I actually lose track of the analytical calculation and how it is performed, hence stuck on the calculation of A_out. Assuming the process is correct…

After multiple attempts, below is one of the errors I get:

As I mainly work intuitively, can someone from the staff help me fix it before it gets weirder?

Thanks in advance!

Hi @Menelaos_Gkikas
In you code after you select the first column to multiply it with a_in, when you used the matmul function you send all weights not the first column to calculate dense result, so use w in the matrix multiplication

Cheers,
Abdelrahman

I understood nothing of what you said, Mr. AbdElRhaman! And I have used quite a shorter code not possible to make such distinctions.

Who can help me visualize and learn what is wrong with my code?

Thanks in advance.

@Menelaos_Gkikas


this image show you that you used capital letter W(carry all weights) in the matrix multiplication instead of using small letter w(carry only the first column)

While it’s definitely true that the devil is in the details, Mr. AbdElRhaman, now this is the error I am being shown at:

Any clue of what might be happening?

@Menelaos_Gkikas
You can use np.matmul(A_in,W) + b that would calculate the matrix multiplication between A_in & W, and in this case you didn’t want to use loop as it would be complicated

Cheers,
Abdelrahman

Now it’s definitely complicated!

Don’t you think we should stop trying to educated guess of what happens and see for yourself what my code is all about?

That’s what I got:

What are we going to do with the js?!

Looking forward for your reply

Cheers!

you wouldn’t use loop, and will use capital letter W without using indexing j

It is far easier to write the code using matrix math functions and avoid the for-loops entirely. Then you don’t have to worry about for-loop and array indices.

It appears that your code is attempting a confusing combination of both for-loops and matrix algebra.

There’s only one thing I can say for your output’s advice, principal mentors:

Zonk!

I’m kinda confused of how to define such a W array. Or that j still exists in the A_out variable.

Can someone from the staff be able to see my code and find out exactly what I mean?

Thanks in advance

That’s what I get now:

Send me your code for that function in a private message, I’ll review it.
A screen capture image is best, that way I can see what indentation you’re using.

@Menelaos_Gkikas
You don’t want to use indexing in the capital letter W you will use direct W like this image below


and also without using indexing in the b and A_out
Note indexing mean that you doing like that …[j]

You don’t need to define this array. It’s already provided as a function argument.

@Menelaos_Gkikas

After complete this assignment, If you want to know the matrix muliplication by using dot product of each column(vectors) with loop send me and I will send it to you.

Regards,
Abdelrahman