forked from open-mmlab/mmdetection
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[docs] Add loss convention (open-mmlab#3818)
* [docs] Add loss convention * add example * fixed backticks * reduce code * fixed lint
- Loading branch information
Showing
3 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Conventions | ||
|
||
Please check the following conventions if you would like to modify MMDetection as your own project. | ||
|
||
## Loss | ||
In MMDetection, a `dict` containing losses and metrics will be returned by `model(**data)`. | ||
|
||
For example, in bbox head, | ||
```python | ||
class BBoxHead(nn.Module): | ||
... | ||
def loss(self, ...): | ||
losses = dict() | ||
# classification loss | ||
losses['loss_cls'] = self.loss_cls(...) | ||
# classification accuracy | ||
losses['acc'] = accuracy(...) | ||
# bbox regression loss | ||
losses['loss_bbox'] = self.loss_bbox(...) | ||
return losses | ||
``` | ||
`bbox_head.loss()` will be called during model forward. | ||
The returned dict contains `'loss_bbox'`, `'loss_cls'`, `'acc'` . | ||
Only `'loss_bbox'`, `'loss_cls'` will be used during back propagation, | ||
`'acc'` will only be used as a metric to monitor training process. | ||
|
||
By default, only values whose keys contain `'loss'` will be back propagated. | ||
This behavior could be changed by modifying `BaseDetector.train_step()`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters