Neural style transfer, programming exercise, compute_content_cost reshape confusion

It’s not transform, it’s transpose, right? That is a very specific mathematical operation. In the first example you show, the point is that the reshape is just the first step. Then you do the transpose. Note that directly reshaping things to the final shape you want is not equivalent and ends up “scrambling” the data. I don’t believe your claim that either form of reshape passes the test. You must not have conducted that experiment correctly: e.g. you changed the code, but didn’t actually click “Shift-Enter” on the changed function cell to get the new code interpreted. So when you called it again you were still running the old code.

To understand why direct reshape without the transpose doesn’t work, here’s a thread from Course 1 about an analogous situation.