[CodeCamp] Add docs about how to freeze the weight of backbone or neck ()

* Add docs about how to freeze the weight of backbone or neck

* refine the docs

* refine the docs

* refine the docs
pull/408/head^2
kitecats 2022-12-31 16:36:40 +08:00 committed by GitHub
parent b1f7e80fe3
commit 14d9cab354
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 50 additions and 0 deletions
docs
en/advanced_guides
zh_cn/advanced_guides

View File

@ -351,6 +351,31 @@ model = dict(
)
```
#### Freeze the weight of backbone or neck
In MMYOLO, we can freeze some `stages` of the backbone network by setting `frozen_stages` parameters, so that these `stage` parameters do not participate in model updating.
It should be noted that `frozen_stages = i` means that all parameters from the initial `stage` to the `i`<sup>th</sup> `stage` will be frozen. The following is an example of `YOLOv5`. Other algorithms are the same logic.
```python
_base_ = './yolov5_s-v61_syncbn_8xb16-300e_coco.py'
model = dict(
backbone=dict(
frozen_stages=1 # Indicates that the parameters in the first stage and all stages before it are frozen
))
```
In addition, it's able to freeze the whole `neck` with the parameter `freeze_all` in MMYOLO. The following is an example of `YOLOv5`. Other algorithms are the same logic.
```python
_base_ = './yolov5_s-v61_syncbn_8xb16-300e_coco.py'
model = dict(
neck=dict(
freeze_all=True # If freeze_all=True, all parameters of the neck will be frozen
))
```
## Output prediction results
If you want to save the prediction results as a specific file for offline evaluation, MMYOLO currently supports both json and pkl formats.

View File

@ -355,6 +355,31 @@ model = dict(
)
```
#### 冻结 backbone 或 neck 的权重
在 MMYOLO 中我们可以通过设置 `frozen_stages` 参数去冻结主干网络的部分 `stage`, 使这些 `stage` 的参数不参与模型的更新。
需要注意的是:`frozen_stages = i` 表示的意思是指从最开始的 `stage` 开始到第 `i``stage` 的所有参数都会被冻结。下面是 `YOLOv5` 的例子,其他算法也是同样的逻辑:
```python
_base_ = './yolov5_s-v61_syncbn_8xb16-300e_coco.py'
model = dict(
backbone=dict(
frozen_stages=1 # 表示第一层 stage 以及它之前的所有 stage 中的参数都会被冻结
))
```
此外, MMYOLO 中也可以通过参数 `freeze_all` 去冻结整个 `neck` 的参数。下面是 `YOLOv5` 的例子,其他算法也是同样的逻辑:
```python
_base_ = './yolov5_s-v61_syncbn_8xb16-300e_coco.py'
model = dict(
neck=dict(
freeze_all=True # freeze_all=True 时表示整个 neck 的参数都会被冻结
))
```
## 输出预测结果
如果想将预测结果保存为特定的文件,用于离线评估,目前 MMYOLO 支持 json 和 pkl 两种格式。