Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleHub
提交
1166014b
P
PaddleHub
项目概览
PaddlePaddle
/
PaddleHub
大约 1 年 前同步成功
通知
282
Star
12117
Fork
2091
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
200
列表
看板
标记
里程碑
合并请求
4
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleHub
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
200
Issue
200
列表
看板
标记
里程碑
合并请求
4
合并请求
4
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
1166014b
编写于
4月 13, 2019
作者:
Z
Zeyu Chen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
migrate BERTFinetune to AdamWeightDecay
上级
1916d77b
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
12 addition
and
12 deletion
+12
-12
demo/ernie-classification/README.md
demo/ernie-classification/README.md
+1
-1
demo/ernie-classification/ernie_tiny_demo.py
demo/ernie-classification/ernie_tiny_demo.py
+1
-1
demo/ernie-classification/question_answering.py
demo/ernie-classification/question_answering.py
+1
-1
demo/ernie-classification/question_matching.py
demo/ernie-classification/question_matching.py
+1
-1
demo/ernie-classification/sentiment_cls.py
demo/ernie-classification/sentiment_cls.py
+1
-1
demo/ernie-seq-labeling/sequence_labeling.py
demo/ernie-seq-labeling/sequence_labeling.py
+1
-1
paddlehub/__init__.py
paddlehub/__init__.py
+1
-1
paddlehub/finetune/finetune.py
paddlehub/finetune/finetune.py
+3
-3
paddlehub/finetune/strategy.py
paddlehub/finetune/strategy.py
+2
-2
未找到文件。
demo/ernie-classification/README.md
浏览文件 @
1166014b
...
...
@@ -95,7 +95,7 @@ with fluid.program_guard(program): # NOTE: 必须使用fluid.program_guard接口
### Step4:选择优化策略并开始Finetune
```
python
strategy
=
hub
.
BERTFinetune
Strategy
(
strategy
=
hub
.
AdamWeightDecay
Strategy
(
weight_decay
=
0.01
,
learning_rate
=
5e-5
,
warmup_strategy
=
"linear_warmup_decay"
,
...
...
demo/ernie-classification/ernie_tiny_demo.py
浏览文件 @
1166014b
...
...
@@ -21,7 +21,7 @@ with fluid.program_guard(program):
feature
=
pooled_output
,
label
=
label
,
num_classes
=
reader
.
get_num_labels
())
# Step4
strategy
=
hub
.
BERTFinetune
Strategy
(
strategy
=
hub
.
AdamWeightDecay
Strategy
(
learning_rate
=
5e-5
,
warmup_proportion
=
0.1
,
warmup_strategy
=
"linear_warmup_decay"
,
...
...
demo/ernie-classification/question_answering.py
浏览文件 @
1166014b
...
...
@@ -62,7 +62,7 @@ if __name__ == '__main__':
pooled_output
,
label
,
num_classes
=
num_labels
)
# Step4: Select finetune strategy, setup config and finetune
strategy
=
hub
.
BERTFinetune
Strategy
(
strategy
=
hub
.
AdamWeightDecay
Strategy
(
weight_decay
=
args
.
weight_decay
,
learning_rate
=
args
.
learning_rate
,
warmup_strategy
=
"linear_warmup_decay"
,
...
...
demo/ernie-classification/question_matching.py
浏览文件 @
1166014b
...
...
@@ -62,7 +62,7 @@ if __name__ == '__main__':
pooled_output
,
label
,
num_classes
=
num_labels
)
# Step4: Select finetune strategy, setup config and finetune
strategy
=
hub
.
BERTFinetune
Strategy
(
strategy
=
hub
.
AdamWeightDecay
Strategy
(
weight_decay
=
args
.
weight_decay
,
learning_rate
=
args
.
learning_rate
,
warmup_strategy
=
"linear_warmup_decay"
,
...
...
demo/ernie-classification/sentiment_cls.py
浏览文件 @
1166014b
...
...
@@ -61,7 +61,7 @@ if __name__ == '__main__':
pooled_output
,
label
,
num_classes
=
reader
.
get_num_labels
())
# Step4: Select finetune strategy, setup config and finetune
strategy
=
hub
.
BERTFinetune
Strategy
(
strategy
=
hub
.
AdamWeightDecay
Strategy
(
weight_decay
=
args
.
weight_decay
,
learning_rate
=
args
.
learning_rate
,
warmup_strategy
=
"linear_warmup_decay"
,
...
...
demo/ernie-seq-labeling/sequence_labeling.py
浏览文件 @
1166014b
...
...
@@ -69,7 +69,7 @@ if __name__ == '__main__':
num_classes
=
num_labels
)
# Select a finetune strategy
strategy
=
hub
.
BERTFinetune
Strategy
(
strategy
=
hub
.
AdamWeightDecay
Strategy
(
weight_decay
=
args
.
weight_decay
,
learning_rate
=
args
.
learning_rate
,
warmup_strategy
=
"linear_warmup_decay"
,
...
...
paddlehub/__init__.py
浏览文件 @
1166014b
...
...
@@ -39,5 +39,5 @@ from .finetune.task import create_text_classification_task
from
.finetune.task
import
create_img_classification_task
from
.finetune.finetune
import
finetune_and_eval
from
.finetune.config
import
RunConfig
from
.finetune.strategy
import
BERTFinetune
Strategy
from
.finetune.strategy
import
AdamWeightDecay
Strategy
from
.finetune.strategy
import
DefaultStrategy
paddlehub/finetune/finetune.py
浏览文件 @
1166014b
...
...
@@ -25,7 +25,7 @@ import numpy as np
from
visualdl
import
LogWriter
from
paddlehub.common.logger
import
logger
from
paddlehub.finetune.strategy
import
BERTFinetune
Strategy
,
DefaultStrategy
from
paddlehub.finetune.strategy
import
AdamWeightDecay
Strategy
,
DefaultStrategy
from
paddlehub.finetune.checkpoint
import
load_checkpoint
,
save_checkpoint
from
paddlehub.finetune.evaluate
import
evaluate_cls_task
,
evaluate_seq_labeling_task
import
paddlehub
as
hub
...
...
@@ -74,7 +74,7 @@ def _finetune_seq_label_task(task,
data_feeder
=
fluid
.
DataFeeder
(
feed_list
=
feed_list
,
place
=
place
)
# Select strategy
if
isinstance
(
config
.
strategy
,
hub
.
BERTFinetune
Strategy
):
if
isinstance
(
config
.
strategy
,
hub
.
AdamWeightDecay
Strategy
):
scheduled_lr
=
config
.
strategy
.
execute
(
loss
,
main_program
,
data_reader
,
config
)
elif
isinstance
(
config
.
strategy
,
hub
.
DefaultStrategy
):
...
...
@@ -173,7 +173,7 @@ def _finetune_cls_task(task, data_reader, feed_list, config=None,
data_feeder
=
fluid
.
DataFeeder
(
feed_list
=
feed_list
,
place
=
place
)
# select strategy
if
isinstance
(
config
.
strategy
,
hub
.
BERTFinetune
Strategy
):
if
isinstance
(
config
.
strategy
,
hub
.
AdamWeightDecay
Strategy
):
scheduled_lr
=
config
.
strategy
.
execute
(
loss
,
main_program
,
data_reader
,
config
)
elif
isinstance
(
config
.
strategy
,
hub
.
DefaultStrategy
):
...
...
paddlehub/finetune/strategy.py
浏览文件 @
1166014b
...
...
@@ -61,7 +61,7 @@ class DefaultStrategy(object):
return
"DefaultStrategy"
class
BERTFinetune
Strategy
(
DefaultStrategy
):
class
AdamWeightDecay
Strategy
(
DefaultStrategy
):
def
__init__
(
self
,
learning_rate
=
1e-4
,
warmup_strategy
=
"linear_warmup_decay"
,
...
...
@@ -114,7 +114,7 @@ class BERTFinetuneStrategy(DefaultStrategy):
# TODO complete __str__()
def
__str__
(
self
):
return
"
BERTFintune
Strategy"
return
"
AdamWeightDecay
Strategy"
class
DefaultFinetuneStrategy
(
DefaultStrategy
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录