# Course 4 week 3 part 1

hello sir

who can help me where I was wrong，I can’t understand，please check the pictures

Your inter_area calculation is wrong. What if the width or height turns out to be a negative value? They talk about how to deal with that in the “Additional Hints” section of the instructions above.

Once you have this debugged, please edit your original post to remove the source code. It sure helps for debugging to see it, but we don’t want to leave it sitting there in perpetuity.

thank you sir，I solve it

1 Like

Congratulations! Thanks for confirming that you found the solution and also thank you for editing out the source code. Onward!

Hi, I am also getting this error, I imagine it is from my calculation of the Union_area. What am I doing wrong please?

AssertionError Traceback (most recent call last)
in
6 print("iou for intersecting boxes = " + str(iou(box1, box2)))
7 assert iou(box1, box2) < 1, “The intersection area must be always smaller or equal than the union area.”
----> 8 assert np.isclose(iou(box1, box2), 0.14285714), “Wrong value. Check your implementation. Problem with intersecting boxes”
9
10 ## Test case 2: boxes do not intersect

AssertionError: Wrong value. Check your implementation. Problem with intersecting boxes

The area of the union is the sum of the individual areas minus the area of the intersection of the two boxes, right? The product of the two areas has nothing to do with the area of the intersection. Please have another look at the instructions: they walk you through computing the intersection area first.

This is how I calculated the intersection and even subtracting the inter_area from the sum is giving an error.

You will always get 0 because you have done the subtractions in the wrong order.

xi2 >= xi1, which means that xi1 - xi2 <= 0, right?

Thank you, it’s working now.

I tested my function outside editor, the iou function is returning exepected values i am getting proper values, the noassert looks to have some undesired behavior,

Sorry, but I think you are misinterpreting the symptoms. What do you mean you can’t print and see values? I don’t have any trouble putting print statements in the iou code.

In the first test case, the inter_area is 1 and the union_area is 7. Here’s the output I get:

``````inter_area 1
union_area 7
iou for intersecting boxes = 0.14285714285714285
``````