Skip to content

Commit

Permalink
Update eval_test.md (#1931)
Browse files Browse the repository at this point in the history
* Update eval_test.md

由于是第一次做文档迁移翻译,所以比较保守,尽可能的按照原来的comment或者原文翻译,没有添加太多的补充润色

* Update eval_test.md

---------

Co-authored-by: Yanhong Zeng <[email protected]>
  • Loading branch information
chg0901 and zengyh1900 authored Jul 13, 2023
1 parent c424634 commit d43496c
Showing 1 changed file with 160 additions and 1 deletion.
161 changes: 160 additions & 1 deletion docs/zh_cn/migration/eval_test.md
Original file line number Diff line number Diff line change
@@ -1 +1,160 @@
# 评测与测试的迁移(待更新)
# 评估与测试设置的迁移

我们更新了 MMagic 1.x 中的评估设置,重要修改如下:

- 评估字段被分为 `val_evaluator``test_evaluator``interval` 被移动到 `train_cfg.val_interval`
- 评估指标从 `test_cfg` 移至 `val_evaluator``test_evaluator`

<table class="docutils">
<thead>
<tr>
<th> 原评估配置 </th>
<th> 新评估配置 </th>
<tbody>
<tr>
<td valign="top">

```python
train_cfg = None # 训练配置字典变量设为 None
test_cfg = dict( # 测试配置字典变量
metrics=['PSNR'], # 测试期间使用的指标 PSNR (峰值信噪比)
crop_border=scale) # 评估期间裁剪边框

evaluation = dict( # 构建评估钩子的配置字典变量
interval=5000, # 评价间隔
save_image=True, # 评估期间保存图像
gpu_collect=True) # 使用 GPU 收集
```

</td>

<td valign="top">

```python
val_evaluator = [
dict(type='PSNR', crop_border=scale), # 要评估的指标名称
]
test_evaluator = val_evaluator

train_cfg = dict(
type='IterBasedTrainLoop', max_iters=300000, val_interval=5000) # 训练循环类型配置
val_cfg = dict(type='ValLoop') # 验证循环类型的名称
test_cfg = dict(type='TestLoop') # 测试循环类型的名称
```

</td>

</tr>
</thead>
</table>

我们已将[MMGeneration 1.x](https://github.com/open-mmlab/mmgeneration/tree/1.x)合并到 MMagic 中.
这里是关于 MMGeneration 的评估和测试设置的迁移。

评估字段分为 `val_evaluator``test_evaluator` ,并且评估字段不再支持 `interval``save_best` 参数。

- `interval` 移至 `train_cfg.val_interval`,请参阅[调度设置](./schedule.md)
- `save_best` 移至 `default_hooks.checkpoint.save_best`

<table class="docutils">
<thead>
<tr>
<th> 0.x 版本 </th>
<th> 1.x 新版本 </th>
<tbody>
<tr>
<td valign="top">

```python
evaluation = dict(
type='GenerativeEvalHook',
interval=10000,
metrics=[
dict(
type='FID',
num_images=50000,
bgr2rgb=True,
inception_args=dict(type='StyleGAN')),
dict(type='IS', num_images=50000)
],
best_metric=['fid', 'is'],
sample_kwargs=dict(sample_model='ema'))
```

</td>

<td valign="top">

```python
val_evaluator = dict(
type='Evaluator',
metrics=[
dict(
type='FID',
prefix='FID-Full-50k',
fake_nums=50000,
inception_style='StyleGAN',
sample_model='orig'),
dict(
type='IS',
prefix='IS-50k',
fake_nums=50000)])
# 设置最佳配置
default_hooks = dict(
checkpoint=dict(
type='CheckpointHook',
interval=10000,
by_epoch=False,
less_keys=['FID-Full-50k/fid'],
greater_keys=['IS-50k/is'],
save_optimizer=True,
save_best=['FID-Full-50k/fid', 'IS-50k/is'],
rule=['less', 'greater']))
test_evaluator = val_evaluator
```

</td>

</tr>
</thead>
</table>

为了正确评估和测试模型,我们需要在 `val_cfg``test_cfg` 中设置特定的循环。

<table class="docutils">
<thead>
<tr>
<th> 0.x 版本中的静态模型 </th>
<th> 1.x 版本中的静态模型 </th>
<tbody>
<tr>
<td valign="top">

```python
total_iters = 1000000

runner = dict(
type='DynamicIterBasedRunner',
is_dynamic_ddp=False,
pass_training_status=True)
```

</td>

<td valign="top">

```python
train_cfg = dict(
by_epoch=False, # 使用基于迭代的训练
max_iters=1000000, # 最大训练迭代次数
val_begin=1,
val_interval=10000) # 评价间隔
val_cfg = dict(type='MultiValLoop') # 验证中的特定循环
test_cfg = dict(type='MultiTestLoop') # 测试中的特定循环
```

</td>

</tr>
</thead>
</table>

0 comments on commit d43496c

Please sign in to comment.