Code Cell UNQ_C1: Unexpected error (AttributeError(“‘list’ object has no attribute ‘get_shape’”)) occurred during function check. We expected function compute_content_cost to return compute_content_cost test 1 failed. Please check that this function is defined properly.
Notes: (not sure how many of these are required to fix the issue):
In your first line of code, since you have a_G available, you can use it there. You can use “.shape”, instead of “get_shape”. You don’t need the [1:] index after it.
In your unrolled code, you don’t need the “perm” parameter, and the shape parameter has a “1,” that it doesn’t need. My code uses transpose and then reshape, not sure if that will make a difference. You might need to swap the order of the shape arguments.
When you compute J_content, use the unrolled a_C and a_G. That’s why they exist in the function. I don’t think the axis parameter is needed.
Also, in the future, please don’t post your code on the forum. That’s not allowed by the code of conduct. If a mentor needs to see your code, we’ll ask you to send it via a private message. I’ll edit the message to remove the code. Thanks!
Hi I have tried what you provided. When I changed the .get_shape to .shape it works. Seems like the grading system does not like this function even though it works in the test section of the jupyter notebook.