W4A2Ex3: Can't seem to figure out what I'm doing wrong

I have already referenced this post to see if I can figure out the answer and did all the steps recommended but I still can’t figure out where I am wrong. I’m getting the exact same error with the exact same value that they got. Someone please help.

I’ve checked a_S and a_G’s shapes and positions as well as the shapes of their corresponding gram matrices.

I’ve also double checked the order of operations on the J_cost function calculation as well as it’s scalar.

Not sure what to do next

1 Like

okay I figured it out but now I have no idea as to why that worked. Like what was the reason for a (idk if I can mention it, may be a hint).

Unless you ask a specific question, we really don’t have anything to answer.

Okay in case I am giving away the answer in any way and its against the policy of the website I will remove the question.

I fixed my issue by transposing the inputs a_S and a_G before unrolling (reshaping) them and I didn’t understand why that seemed to solve the issue. essentially from what I understand we went from a matrix of [n_C, n_H x n_W] to [n_C, n_W x n_H] and this seemed to make a big difference in the calculations of the gram matrix and the subsequent J_cost.

1 Like

It turns out that you can’t directly reshape the inputs into the output shape without the transpose, because it ends up “scrambling” the data. You need to preserve the “channels” dimension. Here is a thread which demonstrates why that happens. It might be a good idea to read that thread from the beginning, not just that post that I highlighted.

This is extremely helpful, especially from the top. Really appreciate the link.

1 Like