# Week 3: Assigning Anchor Boxes

In lecture, Andrew discussed how objects are assigned to both a grid cell and an anchor box. Furthermore, the object is assigned to the anchor box that has the highest IoU with its bounding box.

Let’s say we are using 2 anchor boxes, so, for one grid cell, the output y_pred = [Pc, Bx, By, Bh, Bw, c1, c2, c3, Pc, Bx, By, Bh, Bw, c1, c2, c3] where the first set of 8 values correspond to one anchor box and the next set of 8 values correspond to the other anchor box. Does this mean that the two sets of 8 values are first calculated without worrying which set comes first or last, and then there is a separate step where the bounding boxes are compared (using IoU) to the anchor boxes, at which point the two sets of 8 values are properly ordered to match up with their corresponding anchor box? Assuming the true label vector y is ordered according to anchor boxes across all training examples, does this assignment of objects to anchor boxes simply help the network learn faster, as it doesn’t need to learn, say for example, that it should output taller and skinnier objects as the first set of 8 values in y_pred?

Have you seen the assignment for the week?

One important concept is that ground truth bounding boxes are compared to anchor boxes using IOU, predicted bounding boxes are not.

Ground truth objects are assigned to a location in the Y input matrix of training data using IOU comparison of their ground truth bounding boxes with anchor boxes. Then predictions are made for every location in the output matrix \hat{Y} . The training data and predictions are used to compute error, conceptually Y - \hat{Y}. But IOU of predicted bounding boxes with anchor boxes is not computed.

1 Like

Thank you so much for this clarification! I now realize my misunderstanding.

1 Like

Thanks for the feedback. Glad it helped