Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleOCR
提交
7ea23776
P
PaddleOCR
项目概览
PaddlePaddle
/
PaddleOCR
大约 1 年 前同步成功
通知
1528
Star
32962
Fork
6643
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
108
列表
看板
标记
里程碑
合并请求
7
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleOCR
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
108
Issue
108
列表
看板
标记
里程碑
合并请求
7
合并请求
7
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
7ea23776
编写于
8月 04, 2020
作者:
L
littletomatodonkey
提交者:
GitHub
8月 04, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #479 from littletomatodonkey/add_piecewise
add piecewise decay
上级
f7111d7b
152b099f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
26 addition
and
11 deletion
+26
-11
doc/doc_ch/config.md
doc/doc_ch/config.md
+5
-3
doc/doc_en/config_en.md
doc/doc_en/config_en.md
+5
-3
ppocr/data/rec/img_tools.py
ppocr/data/rec/img_tools.py
+1
-1
ppocr/optimizer.py
ppocr/optimizer.py
+15
-4
未找到文件。
doc/doc_ch/config.md
浏览文件 @
7ea23776
...
...
@@ -60,6 +60,8 @@
| 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 一致 |
| function(decay) | 设置decay方式 | - | 目前支持cosine_decay与piecewise_decay |
| step_each_epoch | 每个epoch包含多少次迭代, cosine_decay时有效 | 20 | 计算方式:total_image_num / (batch_size_per_card
*
card_size) |
| total_epoch | 总共迭代多少个epoch, cosine_decay时有效 | 1000 | 与Global.epoch_num 一致 |
| boundaries | 学习率下降时的迭代次数间隔, piecewise_decay时有效 | - | 参数为列表形式 |
| decay_rate | 学习率衰减系数, piecewise_decay时有效 | - |
\
|
doc/doc_en/config_en.md
浏览文件 @
7ea23776
...
...
@@ -60,6 +60,8 @@ Take `rec_icdar15_train.yml` as an example:
| 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 |
| function(decay) | Set the decay function | cosine_decay | Support cosine_decay and piecewise_decay |
| step_each_epoch | The number of steps in an epoch. Used in cosine_decay | 20 | Calculation :total_image_num / (batch_size_per_card
*
card_size) |
| total_epoch | The number of epochs. Used in cosine_decay | 1000 | Consistent with Global.epoch_num |
| boundaries | The step intervals to reduce learning rate. Used in piecewise_decay | - | The format is list |
| decay_rate | Learning rate decay rate. Used in piecewise_decay | - |
\
|
ppocr/data/rec/img_tools.py
浏览文件 @
7ea23776
...
...
@@ -360,7 +360,7 @@ def process_image(img,
text
=
char_ops
.
encode
(
label
)
if
len
(
text
)
==
0
or
len
(
text
)
>
max_text_length
:
logger
.
info
(
"Warning in ppocr/data/rec/img_tools.py:
line362:
Wrong data type."
"Warning in ppocr/data/rec/img_tools.py: Wrong data type."
"Excepted string with length between 1 and {}, but "
"got '{}'. Label is '{}'"
.
format
(
max_text_length
,
len
(
text
),
label
))
...
...
ppocr/optimizer.py
浏览文件 @
7ea23776
...
...
@@ -36,17 +36,28 @@ def AdamDecay(params, parameter_list=None):
l2_decay
=
params
.
get
(
"l2_decay"
,
0.0
)
if
'decay'
in
params
:
supported_decay_mode
=
[
"cosine_decay"
,
"piecewise_decay"
]
params
=
params
[
'decay'
]
decay_mode
=
params
[
'function'
]
step_each_epoch
=
params
[
'step_each_epoch'
]
total_epoch
=
params
[
'total_epoch'
]
assert
decay_mode
in
supported_decay_mode
,
"Supported decay mode is {}, but got {}"
.
format
(
supported_decay_mode
,
decay_mode
)
if
decay_mode
==
"cosine_decay"
:
step_each_epoch
=
params
[
'step_each_epoch'
]
total_epoch
=
params
[
'total_epoch'
]
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"
)
elif
decay_mode
==
"piecewise_decay"
:
boundaries
=
params
[
"boundaries"
]
decay_rate
=
params
[
"decay_rate"
]
values
=
[
base_lr
*
decay_rate
**
idx
for
idx
in
range
(
len
(
boundaries
)
+
1
)
]
base_lr
=
fluid
.
layers
.
piecewise_decay
(
boundaries
,
values
)
optimizer
=
fluid
.
optimizer
.
Adam
(
learning_rate
=
base_lr
,
beta1
=
beta1
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录