C4 W4 A3 # UNQ_C3 # GRADED FUNCTION: compute_layer_style_cost

it seems my code return a correct value, but received a AssertionError.

I don’t understand the print out that you are showing. Here’s what I get for that test cell:

J_style_layer_GG 0.0
J_style_layer_SG 14.017805099487305
J_style_layer = tf.Tensor(14.017805, shape=(), dtype=float32)

Note that the GG case comes first. But you show the other case first. I’m guessing those are internal prints in your function. Did you edit the test cell to run things in the opposite order? Most of the test cells in the notebooks are not editable, but in this notebook they are.

yes, the prints is in my def function cell, and I put the GS first.
I followed your suggestion, and it works now
thank you

but why the order matters? as dist(a,b) and dist(b,a) are both scalar, i think they should be same.

Maybe I’m just missing your point, but I think you need to read a bit more carefully. If you look at the logic of the cost function, like any distance metric, it is symmetric, meaning that the order of the arguments doesn’t matter. The point is that the two test cases are different: they don’t just flip the order of the arguments. It is dist(a,a) and dist(a,b). That is not the same thing.