Course 4 Week 3 yolo_non_max_suppression

I got the following error in “yolo_non_max_suppression” and can’t find the failure in code by myself:

InvalidArgumentError: Value for attr ‘Tindices’ of float is not in the list of allowed values: int32, int64
; NodeDef: {{node GatherV2}}; Op<name=GatherV2; signature=params:Tparams, indices:Tindices, axis:Taxis → output:Tparams; attr=batch_dims:int,default=0; attr=Tparams:type; attr=Tindices:type,allowed=[DT_INT32, DT_INT64]; attr=Taxis:type,allowed=[DT_INT32, DT_INT64]> [Op:GatherV2]

The above error caused by code
scores = tf.gether(…), I put nms_indices, scores in the bracket and didn’t specify more parameters like axis ect.

Could you please help me? Thank you very much!

Heyo, Can you check if the order of arguments you passed them into tf.gather correct? From what it looks to me, you might have passed the scores instead of indices there which is causing the error.

Thank you very much for your quick reply.
I changed the code to scores = tf.gather(nms_indices, indices=1).numpy(), and still got error messages:

AssertionError: Use tensoflow functions

It seems to that parameter “scores” was not calculated correctly.

I tried to bugfix the code and came to the conclusion that I can’t solve the problem by myself. I got the result for scores, box and classes not as tensoflow.
the code got stuck at
assert type(scores) == EagerTensor, “Use tensoflow functions”

Could you please help me?

Hey, you should not need to do a .numpy here, and you don’t need to pass a separate indices argument along with the nms_indices variable you have here. You already have the references for all three scores, boxes and classes and you have an indices variable. Check the syntax for keras.gather provided before the function and you should be able to fix this.

I tried w/o .nupmpy(). It didn’t work either. tf.gather() should be correct, isn’t it?

The arguments you are passing to it are not correct.

I should have read through the introduction of tf.gather very thoughtfully. I finally figured it out how do the inputs mean. Thank you very much!