Course 4, Week 3, Part 1: yolo_filter_boxes function problem


Im not sure what is wrong getting the shapes and datatypes till filtering mask right after applying them it goes all wrong.If you someone could guide me in the right direction I would be grateful

The shapes of scores, boxes, and classes depend on the number of elements that exceed the filtering threshold, which in turn depends on the random initialization of box_scores. Notice that your individual values are different from what @paulinpaloalto shows above, as well as the shapes. Check your random initialization, as well as whether you added any print statements that might cause the random number sequence to increment.

I don’t think random initialization is the problem, I started on a fresh notebook I am still having the same issues its probably has something to do with box_class_scores. Cant figure out what though.

\le vs \lt is another thing that could account for different counts passing the threshold (or inequality inverted)

yup I have checked that too,still having same issue .box_class_scores calls reduce_sum and uses box_scores with axis -1 as inputs right?

It’s reduce_max, not reduce_sum, right?

2 Likes

yup,your right called the wrong function,thanks a lot for your help

1 Like

I looked through this thread, but still can’t figure out my issue as below. The dimension looks right. Both box_classes and box_class_scores are computed from box_scores on axis=-1, right?

box_scores.shape: (19, 19, 5, 80)
box_scores.type: <class 'tensorflow.python.framework.ops.EagerTensor'>
box_classes.shape: (19, 19, 5)
box_class_scores.shape: (19, 19, 5)
filtering_mask.shape: (19, 19, 5) filtering_mask.type: <class 'tensorflow.python.framework.ops.EagerTensor'>
scores[2] = [ -6.947019     0.06495993  -0.09231107   1.9229256   -8.933988
   4.266996    -2.5233626   -1.0357457    9.270486    -6.093267
 -14.030916    -4.884537     5.704059    -4.1289454   -6.1082263
   1.7578557    4.355549    -6.43128     -2.4484224    3.2742531
  -1.786569    -4.6719904   -3.7101617    2.0244038   -0.21229683
   0.7752132    4.1586823   -3.4750829    5.502074     0.05799035
   3.4069664   -3.757799     4.006846    -2.3703334   -3.342284
  -4.293213    -2.5573728   -1.8982053   -1.1549497   -0.8022735
  -1.8169211    1.3455609   -6.429533    -2.5119228    2.8919446
  -5.360439    -1.5676502   -4.3315964   -6.0917664   -4.5209737
  -2.929725    -1.7455465   -3.1875036    1.1328714   -1.5746784
   0.0923316    1.9777262    0.86132324   7.4806495    2.619351
  -1.4033728   -1.739711     0.254833    -0.38542864  -2.9211323
   7.1019955   -6.438033     3.5228815   -2.1012435   -4.932968
  -2.1174386    4.462003    -4.8623567   -1.3148922   -1.9493929
  -4.421925     3.70371     -0.9842584    3.7049224    1.8417823 ]
boxes[2] = [ 4.6399336  3.2303846  4.431282  -2.202031 ]
classes[2] = 8
scores.shape = (1789, 80)
boxes.shape = (1789, 4)
classes.shape = (1789,)
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-33-2cab1199ef30> in <module>
     16 assert type(classes) == EagerTensor, "Use tensorflow functions"
     17 
---> 18 assert scores.shape == (1789,), "Wrong shape in scores"
     19 assert boxes.shape == (1789, 4), "Wrong shape in boxes"
     20 assert classes.shape == (1789,), "Wrong shape in classes"

AssertionError: Wrong shape in scores

My ‘scores’ used the original tensor, instead of the maxed tensor. I fixed it.

1 Like