Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wangsen
paddle_dbnet
Commits
b47b5521
Unverified
Commit
b47b5521
authored
Jun 15, 2020
by
Double_V
Committed by
GitHub
Jun 15, 2020
Browse files
Merge pull request #184 from tink2123/add_cosine_decay
add cosine decay
parents
1963d80d
b27207ba
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
0 deletions
+49
-0
configs/rec/rec_icdar15_train.yml
configs/rec/rec_icdar15_train.yml
+4
-0
doc/doc_ch/config.md
doc/doc_ch/config.md
+15
-0
doc/doc_en/config_en.md
doc/doc_en/config_en.md
+15
-0
ppocr/optimizer.py
ppocr/optimizer.py
+15
-0
No files found.
configs/rec/rec_icdar15_train.yml
View file @
b47b5521
...
@@ -41,3 +41,7 @@ Optimizer:
...
@@ -41,3 +41,7 @@ Optimizer:
base_lr
:
0.0005
base_lr
:
0.0005
beta1
:
0.9
beta1
:
0.9
beta2
:
0.999
beta2
:
0.999
decay
:
function
:
cosine_decay
step_each_epoch
:
20
total_epoch
:
1000
doc/doc_ch/config.md
View file @
b47b5521
...
@@ -46,3 +46,18 @@
...
@@ -46,3 +46,18 @@
| img_set_dir | 数据集路径 | ./train_data |
\
|
| img_set_dir | 数据集路径 | ./train_data |
\
|
| label_file_path | 数据标签路径 | ./train_data/rec_gt_train.txt|
\
|
| label_file_path | 数据标签路径 | ./train_data/rec_gt_train.txt|
\
|
| infer_img | 预测图像文件夹路径 | ./infer_img |
\|
| infer_img | 预测图像文件夹路径 | ./infer_img |
\|
## 配置文件 Optimizer 系列参数介绍
以
`rec_icdar15_train.yml`
为例
| 字段 | 用途 | 默认值 | 备注 |
| :---------------------: | :---------------------: | :--------------: | :--------------------: |
| function | 选择优化器 | pocr.optimizer,AdamDecay | 目前只支持Adam方式 |
| base_lr | 设置初始学习率 | 0.0005 |
\
|
| beta1 | 设置一阶矩估计的指数衰减率 | 0.9 |
\
|
| beta2 | 设置二阶矩估计的指数衰减率 | 0.999 |
\
|
| decay | 是否使用decay |
\
|
\
|
| function(decay) | 设置decay方式 | cosine_decay | 目前只支持cosin_decay |
| step_each_epoch | 每个epoch包含多少次迭代 | 20 | 计算方式:total_image_num / (batch_size_per_card
*
card_size) |
| total_epoch | 总共迭代多少个epoch | 1000 | 与Global.epoch_num 一致 |
doc/doc_en/config_en.md
View file @
b47b5521
...
@@ -46,3 +46,18 @@ Take `rec_chinese_reader.yml` as an example:
...
@@ -46,3 +46,18 @@ Take `rec_chinese_reader.yml` as an example:
| img_set_dir | Image folder path | ./train_data |
\
|
| img_set_dir | Image folder path | ./train_data |
\
|
| label_file_path | Groundtruth file path | ./train_data/rec_gt_train.txt|
\
|
| label_file_path | Groundtruth file path | ./train_data/rec_gt_train.txt|
\
|
| infer_img | Result folder path | ./infer_img |
\|
| infer_img | Result folder path | ./infer_img |
\|
## Introduction to Optimizer parameters of Configuration file
Take
`rec_icdar15_train.yml`
as an example:
| Parameter | Use | Default | None |
| :---------------------: | :---------------------: | :--------------: | :--------------------: |
| function | Select Optimizer function | pocr.optimizer,AdamDecay | Only support Adam |
| base_lr | Set the base lr | 0.0005 |
\
|
| beta1 | Set the exponential decay rate for the 1st moment estimates | 0.9 |
\
|
| beta2 | Set the exponential decay rate for the 2nd moment estimates | 0.999 |
\
|
| decay | Whether to use decay |
\
|
\
|
| function(decay) | Set the decay function | cosine_decay | Only support cosine_decay |
| step_each_epoch | The number of steps in an epoch. | 20 | Calculation :total_image_num / (batch_size_per_card
*
card_size) |
| total_epoch | The number of epochs | 1000 | Consistent with Global.epoch_num |
ppocr/optimizer.py
View file @
b47b5521
...
@@ -15,6 +15,9 @@ from __future__ import absolute_import
...
@@ -15,6 +15,9 @@ from __future__ import absolute_import
from
__future__
import
division
from
__future__
import
division
from
__future__
import
print_function
from
__future__
import
print_function
import
paddle.fluid
as
fluid
import
paddle.fluid
as
fluid
from
ppocr.utils.utility
import
initial_logger
logger
=
initial_logger
()
def
AdamDecay
(
params
,
parameter_list
=
None
):
def
AdamDecay
(
params
,
parameter_list
=
None
):
...
@@ -28,6 +31,18 @@ def AdamDecay(params, parameter_list=None):
...
@@ -28,6 +31,18 @@ def AdamDecay(params, parameter_list=None):
base_lr
=
params
[
'base_lr'
]
base_lr
=
params
[
'base_lr'
]
beta1
=
params
[
'beta1'
]
beta1
=
params
[
'beta1'
]
beta2
=
params
[
'beta2'
]
beta2
=
params
[
'beta2'
]
if
'decay'
in
params
:
params
=
params
[
'decay'
]
decay_mode
=
params
[
'function'
]
step_each_epoch
=
params
[
'step_each_epoch'
]
total_epoch
=
params
[
'total_epoch'
]
if
decay_mode
==
"cosine_decay"
:
base_lr
=
fluid
.
layers
.
cosine_decay
(
learning_rate
=
base_lr
,
step_each_epoch
=
step_each_epoch
,
epochs
=
total_epoch
)
else
:
logger
.
info
(
"Only support Cosine decay currently"
)
optimizer
=
fluid
.
optimizer
.
Adam
(
optimizer
=
fluid
.
optimizer
.
Adam
(
learning_rate
=
base_lr
,
learning_rate
=
base_lr
,
beta1
=
beta1
,
beta1
=
beta1
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment