Neural style transfer, programming exercise, compute_content_cost reshape confusion

I explained that in my first reply: what they show you is only the first step that is required. Then you need the transpose to get to the final desired shape.

The point is that you need to preserve the “channels” dimension in the output, so that it ends up as the first dimension. Directly doing the reshape does not do that. It is the same as in the “flattening” example I gave earlier. Please read that thread again and study carefully how reshape works.

But if you had just followed the hints that they gave you of first doing the reshape to n_H * n_W, n_C then it would have worked, even without really understanding why. But I grant you they could have explained more thoroughly.

Ok, let me run some experiments and see if I can reproduce your results.