C4W3: .gather() does not seem to work as intended

in the “yolo_non_max_suppression” function, i follow the instructions given which are as present in the comments

        # Append the resulting boxes into the partial result
        # Use tf.gather() with 'selected_indices' and `nms_indices_label`

and the code i wrote
{mentor edit: removed exact description of code}

but this gives me this error:
InvalidArgumentError: indices[0] = 1 is not in [0, 1) [Op:GatherV2]

i spent lots of time on it and even went through the docs of the function, but cant seem to figure it out, can anyone help me out with this

You have the order of the function parameters backward.

I did change the order(selected_indices first and then nms_indices_label as does make sense, i get that .gather() picks the elements from the param which have the same indices as present in the second param) but then i get this

InvalidArgumentError: indices[1] = 1 is not in [0, 1) [Op:GatherV2]

and the error points to this line itself, so the rest of the code is fine

Perhaps your code that creates the nms_indices_label is incorrect.

Note: Describing your code in exact detail is just the same as posing the code itself. Neither is allowed.

Please only include screen capture images that show the entire error message.

yup got it now, it was indeed in the nms_indices_label

That’s good news, thanks for the update.

1 Like