[C3W2_Assignment] Zombie detector

Hi,
I tried to found issue many times but I am not able to find it yet. I rerun the lab many times but I do not understand where is the problem. All outputs are according to expected output but when I predict it gives the following error. Please look the following:

Start fine-tuning!

ValueError Traceback (most recent call last)
in <cell line: 3>()
15
16 # Training step (forward pass + backwards pass)
—> 17 total_loss = train_step_fn(image_tensors,
18 gt_boxes_list,
19 gt_classes_list,

4 frames
/usr/local/lib/python3.10/dist-packages/object_detection/core/losses.py in if_body()
42 def if_body():
43 nonlocal target_tensor
—> 44 target_tensor = ag__.converted_call(ag__.ld(tf).where, (ag__.converted_call(ag__.ld(tf).is_nan, (ag__.ld(target_tensor),), None, fscope), ag__.ld(prediction_tensor), ag__.ld(target_tensor)), None, fscope)
45
46 def else_body():

ValueError: in user code:

File "<ipython-input-79-7eb5bf045b59>", line 52, in train_step_fn  *
    losses_dict = model.loss(prediction_dict, true_shape_tensor)
File "/usr/local/lib/python3.10/dist-packages/object_detection/meta_architectures/ssd_meta_arch.py", line 876, in loss  *
    location_losses = self._localization_loss(
File "/usr/local/lib/python3.10/dist-packages/object_detection/core/losses.py", line 78, in __call__  *
    target_tensor = tf.where(tf.is_nan(target_tensor),

ValueError: Shapes must be equal rank, but are 3 and 1 for '{{node Loss/Loss/Select}} = Select[T=DT_FLOAT](Loss/Loss/IsNan, concat_1, Loss/stack_2)' with input shapes: [0], [4,51150,4], [0].

Codes incorrect for total loss,

Check if your image tensor is of equal shape, there is a mismatch. Check after object detection grader cell again

1 Like

Hi @Deepti_Prasad, thanks for the reply.
I do the same according to instructions. But still not figuring out if it is a problem in loss.
I did the following to calculate the loss.
losses_dict = model.loss(prediction_dict, true_shape_tensor)
total_loss = losses_dict[‘Loss/localization_loss’] + losses_dict[‘Loss/classification_loss’]

Can someone please guide me? My deadline is very close to complete it.

Hello Waqar
I am in journey, will surely reply by tomorrow as early as possible once I reach home. Sorry for the delay. Your codes are incorrect. In case you can look either ungraded lab or you can look for the same issue in the discourse community. I think I have replied to a similar thread, or someone else has also replied for the same issue. Try searching with the error you got and choose the appropriate specifications, course and week when you are searching for similar post threads for your issue. If you don’t get till tomorrow morning, I will surely let you know by tomorrow.

Regards
DP

Thank you @Deepti_Prasad. I fixed the issue. The issue was in the get box list, I was not generating them correctly because above it becomes empty, and we need to redefine them again in the loop.

1 Like