-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Doc] Add Chinese doc for tutorials05_training_tricks_md #631
Merged
Junjun2016
merged 21 commits into
open-mmlab:doc_zh
from
MengzhangLI:tutorial_training_tricks_md
Jul 2, 2021
Merged
Changes from 18 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
8a9deea
get_started_docs_zh
MengzhangLI 5369c21
inference_zh.md
MengzhangLI 04d2e67
train_zh.md
MengzhangLI 178194e
get_started_zh.md
MengzhangLI 5d9055a
train_zh.md
MengzhangLI 60cbc6e
get_started_zh
MengzhangLI da616df
fix nospace between ZH and ENG
MengzhangLI 6adb79e
change README_zh-CN link
MengzhangLI 12afb80
checkout space again
MengzhangLI 6ddb19d
checkout space again
MengzhangLI 42908c5
checkout space again
MengzhangLI e5a0265
pipeline
MengzhangLI 0b942b1
cus_model
MengzhangLI faec079
cus_model
MengzhangLI fb7ef56
cus_model
MengzhangLI bc8c01e
traning tricks md
MengzhangLI a7d4dbc
traning tricks md
MengzhangLI a8870d5
refine
MengzhangLI 35e8f07
refine
MengzhangLI 0f5b626
refine
MengzhangLI dbbd9d0
Update training_tricks.md
Junjun2016 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
@@ -1 +1,51 @@ | ||
# 教程 5: 训练小技巧 | ||
# 教程 5: 训练技巧 | ||
|
||
MMSegmentation 支持如下训练技巧: | ||
|
||
## 主干网络和头组件使用不同的学习率 (Learning Rate, LR) | ||
|
||
在语义分割里,一些方法会让头组件的学习率大于骨架组件的学习率,这样可以获得更好的表现或更快的收敛。 | ||
|
||
在 MMSegmentation 里面,您也可以在配置文件里添加如下行来让头组件的学习率是骨架组件的10倍。 | ||
|
||
```python | ||
optimizer=dict( | ||
paramwise_cfg = dict( | ||
custom_keys={ | ||
'head': dict(lr_mult=10.)})) | ||
``` | ||
|
||
通过这种修改,任何被分组到 `'head'` 的参数的学习率都将乘以10。您也可以参照 [MMCV 文档](https://mmcv.readthedocs.io/en/latest/api.html#mmcv.runner.DefaultOptimizerConstructor) 获取更详细的信息。 | ||
|
||
## 在线难样本挖掘 (Online Hard Example Mining, OHEM) | ||
|
||
对于训练时采样,我们在 [这里](https://github.com/open-mmlab/mmsegmentation/tree/master/mmseg/core/seg/sampler) 做了像素采样器。 | ||
如下例子是使用 PSPNet 训练并采用 OHEM 策略的配置: | ||
|
||
```python | ||
_base_ = './pspnet_r50-d8_512x1024_40k_cityscapes.py' | ||
model=dict( | ||
decode_head=dict( | ||
sampler=dict(type='OHEMPixelSampler', thresh=0.7, min_kept=100000)) ) | ||
``` | ||
|
||
通过这种方式,只有置信分数在0.7以下的像素值点会被拿来训练。在训练时我们至少要保留100000个像素值点。如果 `thresh` 并未被指定,前 ``min_kept`` | ||
个损失的像素值点才会被选择。 | ||
|
||
## 类别平衡损失 (Class Balanced Loss) | ||
|
||
对于没有平衡类别分布的数据集,您也许可以改变每个类别的损失权重。这里以 cityscapes 数据集为例: | ||
|
||
```python | ||
_base_ = './pspnet_r50-d8_512x1024_40k_cityscapes.py' | ||
model=dict( | ||
decode_head=dict( | ||
loss_decode=dict( | ||
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0, | ||
# DeepLab 对 cityscapes 使用这种权重 | ||
class_weight=[0.8373, 0.9180, 0.8660, 1.0345, 1.0166, 0.9969, 0.9754, | ||
1.0489, 0.8786, 1.0023, 0.9539, 0.9843, 1.1116, 0.9037, | ||
1.0865, 1.0955, 1.0865, 1.1529, 1.0507]))) | ||
``` | ||
|
||
`class_weight` 将被作为 `weight` 参数,传递给 `CrossEntropyLoss`。详细信息请参照 [PyTorch 文档](https://pytorch.org/docs/stable/nn.html?highlight=crossentropy#torch.nn.CrossEntropyLoss) 。 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may replace them all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I will replace all of it in every single doc.