C4 W3 A1Ex 3 Multiple values for argument 'iou_threshold'

After consulting the tf.image,non_max_supression documentation and trying several variations of the “iou_threshold” argument in the tf.image.non_max_suppression() line (e.g. "iou_threshold’, “iou_threshold = iou_threshold,” “score_threshold = iou_threshold”, and others), i still keep getting the aforementioned error. Any guidance?

TypeError Traceback (most recent call last)
4 boxes = tf.random.normal([54, 4], mean=1, stddev=4, seed = 1)
5 classes = tf.random.normal([54,], mean=1, stddev=4, seed = 1)
----> 6 scores, boxes, classes = yolo_non_max_suppression(scores, boxes, classes)
8 assert type(scores) == EagerTensor, “Use tensoflow functions”

in yolo_non_max_suppression(scores, boxes, classes, max_boxes, iou_threshold)
27 # Use tf.image.non_max_suppression() to get the list of indices corresponding to boxes you keep
28 ##(≈ 1 line)
—> 29 nms_indices = tf.image.non_max_suppression(boxes, scores, classes, max_boxes_tensor, iou_threshold = 0.5)
31 # Use tf.gather() to select only nms_indices from scores, boxes and classes

/opt/conda/lib/python3.7/site-packages/tensorflow/python/util/dispatch.py in wrapper(*args, **kwargs)
199 “”“Call target, and fall back on dispatchers if there is a TypeError.”""
200 try:
→ 201 return target(*args, **kwargs)
202 except (TypeError, ValueError):
203 # Note: convert_to_eager_tensor currently raises a ValueError, not a

TypeError: non_max_suppression() got multiple values for argument ‘iou_threshold’

1 Like

Take a more careful look at the documentation for tf.image.non_max_suppression. iou_threshold is the 4th parameter, but you’ve supplied it as a named parameter in the 5th slot. That’s why it is kvetching at you about multiple values. Or maybe it’s the fact that the argument you supplied in the 4th slot is a tensor instead of a scalar.

Also note that we’re running TF 2.3.0 here, so we don’t have the score_threshold parameter, as they point out in the instructions in the notebook.

Hey paulinpaloalto;
When i followed your guidance and rearranged arguments everything worked. I must admit i would have never arrived at this solution because i thought the extra parameter i had used was a vital requirement for tf.image.non_max_suppression() to work. Many thanks!