Help with Course 1, Week 3 Assignment, Exercise 6

Hello, my name is Ramiz and I am enrolled in the Neural Networks and Deep Learning Module.

I am working on the Assignment of Week 3 of Course 1. I am unable to compute the dZ1 derivative because because two of the arrays that I have to matrix-multiply have the same shape - specifically the arrays for g[1]'(z) and Z1. My previous lines of code for the assignment are so far correct so I do not understand where the mistake comes from or how to fix it. Does someone have a clue they might share with me?

The crux of the problem I have is that both g[1]'(z) and Z1 have shape (4, 3), so they cannot be dot-multiplied. I computed Z1 earlier so its (4, 3) shape is correct. Therefore dZ1 should also have shape (4, 3), but not g[1]'(z).

I’m not that familiar with the assignment right now, but aren’t you supposed to transpose one of them? Can you check the instructions of the exercises properly, because you might need to transpose one of them.

Never mind, I had misunderstood a portion of the equation used to calculate dZ1, it works correctly now. I thought that I had to multiply g[1]' with Z1, but the notation of the equation had confused me, the calculation shown in the lecture notes is g[1]'(Z1). Z1 is a variable of g[1]', they are not multiplied by one another.

Hi Ramiz @Ramiz_Haditalab Welcome to community ! :tada:,

If you’d like to dive deeper into the full mathematical derivations of Backpropagation, Vectorization, and how partial derivatives work across layer vectors, I highly recommend checking out this pinned community resource:

:pushpin: Feedforward Neural Networks in Depth (Check the reference thread under Deep Learning Resources)

It breaks down the chain rule and matrix calculus step-by-step with great clarity. It’s a fantastic read once you get comfortable with your assignments and your intuition in general

It’s great to hear that you figured out the issue here and that it was just a misunderstanding of the notation. Note that there are two forms of matrix multiplication: the usual “dot product” style and also there is “elementwise” multiplication which is used in some cases. It is worth taking a look at this thread which explains the notation that Professor Ng uses to distinguish those two very different operations. Note that you can also find that as one of the topics on the DLS FAQ Thread, which is worth a look if you are just getting started on DLS.