DLS Course 4, Week 4, Assignment 2 - AssertionError: Use the tensorflow function

Hi,

The below question is for # UNQ_C1 compute_content_cost function

When running the test, I’m getting an error with the below output :

AssertionError Traceback (most recent call last)
Input In [25], in <cell line: 3>()
1 ### you cannot edit this cell
----> 3 compute_content_cost_test(compute_content_cost)

File /tf/W4A2/public_tests.py:12, in compute_content_cost_test(target)
10 J_content = target(a_C, a_G)
11 J_content_0 = target(a_C, a_C)
—> 12 assert type(J_content) == EagerTensor, “Use the tensorflow function”
13 assert np.isclose(J_content_0, 0.0), “Wrong value. compute_content_cost(A, A) must be 0”
14 assert np.isclose(J_content, 7.0568767), f"Wrong value. Expected {7.0568767}, current{J_content}"

AssertionError: Use the tensorflow function

#######

However, when I print using “print(type(J_content))”, I get the below output :
<class ‘tensorflow.python.framework.ops.EagerTensor’>

How do I solve this?

Regards,

Sagar

Are you sure that you didn’t use any numpy functions in the compute graph? E.g. numpy transpose or numpy reshape?

Yes, I’m sure of that.

Throughout, I have used tensorflow functions - tf.reshape, tf.reduce_sum, tf.square and tf.subtract.
tf.transpose wasn’t needed for this function.