# How to calculate the class probability of a grid cell in YOLO object detection algorithm?

I am going through the YOLO paper by Redmon, Divvala, Girshick & Farhadi (2015), "You Only Look Once: Unified, Real-Time Object Detection" (arXiV page here )

On the fourth page it mentions the loss function. It's a combined regression loss function.

What I don't understand in how to get the classification error or to find the probability of the class on each grid cell by optimizing it's regression loss.

Here's the YOLO loss function mentioned in it: • Please give a full reference (title, authors, year) in your question and quote the essential parts. The link would probably be better as the arXiV page as it's more likely to be stable in the longer term (and findable if it moves). If at all possible, you should quote enough information/context form the paper that someone might still be able to attempt an answer if they couldn't read the paper, or as near as you can reasonably get with some short quotes/explanation. While editing, please fix the spelling error in the title. (You should also ask a question.) – Glen_b Apr 27 '17 at 10:50
• Thanks for the edit; it's a good start. However it's not really sufficient since there's not enough context in the question itself. – Glen_b Apr 27 '17 at 12:05
• could you please publish this. I really want to know this. – Shamane Siriwardhana Apr 28 '17 at 4:03
• You didn't need me to do it personally; as soon as you edited it went into the review queue. The problem was likely that you hadn't done enough yet for people to vote to reopen and you needed to edit more. I have made some of the changes I asked for. Ideally the image of the page should be replaced with MathJax markup but this will do for the moment – Glen_b Apr 28 '17 at 5:28

## 1 Answer

Classification loss is included in the formula above. In particular, the term: $$\sum_{i=0}^{S^2} \mathbb{1}_i^{obj}\sum_{c \in classes}(p_i(c) - \hat{p}_i(c))^2$$ corresponds to this description in the paper:

Each grid cell also predicts $C$ conditional class probabilities $Pr(Class_i|Object)$... We only predict one set of class probabilities per grid cell, regardless of the number of boxes $B$.

$Pr(Class_i)$ is equivalent to $p_i(c)$ in the loss. Notice that this description matches the fact that the term above does not sum over $B$, the number of bboxes per grid cell.

• I do agree that the notation in the paper could be much better; the loss function is also not explicitly described (i.e., definitions are not explicitly matched to the loss function's terms). This is a pain! – acnalb May 18 '17 at 18:08
• yes I was searching for that. so each grid cell can be belongs to a one single class. that class is the box with highest ROC belongs to right? because here the regression should produce probabilities related to each class for a single grid cell. – Shamane Siriwardhana May 18 '17 at 22:00
• yes I was searching for that. so each grid cell can be belongs to a one single class. that class is the box with highest ROC belongs to right? because here the regression should produce probabilities related to each class for a single grid cell. So as we were talking if the number of classes are 10 , target probabilities for a single grid should be 1 for correct class and 0s for all other 9 classes. And we select the correct class for one grid cell as the class that belongs to largest IOU. – Shamane Siriwardhana May 18 '17 at 22:05
• What do you mean by ROC? Yes, each grid cell can belong only to a single class. The chosen class is the one with the highest probability output by the fully-connected layers at the end of the net. – acnalb May 19 '17 at 1:21