W4A2E3 - same code, different outcome

To retrieve the dims of the tensor, I use the suggested “get shape as list” command. It passes the first exercise, but at the third, it says there’s only 1 instead of 4 values there.

Is this the real reason? I’d rather guess the error is something else, and the dim issue is merely an excuse. Thanks in advance.

Yes, my guess is that the bug is not in compute_content_cost where the error is thrown. The bug is that you are calling compute_content_cost incorrectly. I checked my code and nowhere in compute_layer_style_cost does it call compute_content_cost. It looks like you are passing a “gram” matrix as the argument, which is why it “throws”.

Why are you calling compute_content_cost at that point in the code? They give you the formula for the style cost that you need to implement in section 4.2.2 of the instructions. You implement it directly with the Gram matrices and some TF functions.

Thanks for the reminder. There is a hint of using previous exercise’s result for the previous subquestion, and I mistakenly think the next is applicable as well.