Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
99a5a3d8
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
99a5a3d8
编写于
6月 04, 2018
作者:
S
Siddharth Goyal
提交者:
GitHub
6月 04, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix optimizer in remaining chapters with high level API (#11172)
上级
c9067bef
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
60 addition
and
32 deletion
+60
-32
python/paddle/fluid/tests/book/high-level-api/CMakeLists.txt
python/paddle/fluid/tests/book/high-level-api/CMakeLists.txt
+6
-6
python/paddle/fluid/tests/book/high-level-api/image_classification/test_image_classification_resnet.py
.../image_classification/test_image_classification_resnet.py
+5
-3
python/paddle/fluid/tests/book/high-level-api/image_classification/test_image_classification_vgg.py
...api/image_classification/test_image_classification_vgg.py
+5
-3
python/paddle/fluid/tests/book/high-level-api/machine_translation/test_machine_translation.py
...level-api/machine_translation/test_machine_translation.py
+9
-5
python/paddle/fluid/tests/book/high-level-api/recognize_digits/test_recognize_digits_conv.py
...-level-api/recognize_digits/test_recognize_digits_conv.py
+5
-2
python/paddle/fluid/tests/book/high-level-api/recognize_digits/test_recognize_digits_mlp.py
...h-level-api/recognize_digits/test_recognize_digits_mlp.py
+5
-2
python/paddle/fluid/tests/book/high-level-api/recommender_system/test_recommender_system_newapi.py
...-api/recommender_system/test_recommender_system_newapi.py
+5
-2
python/paddle/fluid/tests/book/high-level-api/understand_sentiment/test_understand_sentiment_conv.py
...pi/understand_sentiment/test_understand_sentiment_conv.py
+5
-2
python/paddle/fluid/tests/book/high-level-api/understand_sentiment/test_understand_sentiment_dynamic_rnn.py
...rstand_sentiment/test_understand_sentiment_dynamic_rnn.py
+5
-2
python/paddle/fluid/tests/book/high-level-api/understand_sentiment/test_understand_sentiment_stacked_lstm.py
...stand_sentiment/test_understand_sentiment_stacked_lstm.py
+5
-2
python/paddle/fluid/tests/book/high-level-api/word2vec/test_word2vec_new_api.py
...sts/book/high-level-api/word2vec/test_word2vec_new_api.py
+5
-3
未找到文件。
python/paddle/fluid/tests/book/high-level-api/CMakeLists.txt
浏览文件 @
99a5a3d8
...
...
@@ -7,10 +7,10 @@ foreach(src ${TEST_OPS})
endforeach
()
add_subdirectory
(
fit_a_line
)
#
add_subdirectory(recognize_digits)
#
add_subdirectory(image_classification)
#
add_subdirectory(understand_sentiment)
add_subdirectory
(
recognize_digits
)
add_subdirectory
(
image_classification
)
add_subdirectory
(
understand_sentiment
)
add_subdirectory
(
label_semantic_roles
)
#
add_subdirectory(word2vec)
#
add_subdirectory(recommender_system)
#
add_subdirectory(machine_translation)
add_subdirectory
(
word2vec
)
add_subdirectory
(
recommender_system
)
add_subdirectory
(
machine_translation
)
python/paddle/fluid/tests/book/high-level-api/image_classification/test_image_classification_resnet.py
浏览文件 @
99a5a3d8
...
...
@@ -85,6 +85,10 @@ def train_network():
return
[
avg_cost
,
accuracy
]
def
optimizer_func
():
return
fluid
.
optimizer
.
Adam
(
learning_rate
=
0.001
)
def
train
(
use_cuda
,
train_program
,
params_dirname
):
BATCH_SIZE
=
128
EPOCH_NUM
=
1
...
...
@@ -111,9 +115,7 @@ def train(use_cuda, train_program, params_dirname):
place
=
fluid
.
CUDAPlace
(
0
)
if
use_cuda
else
fluid
.
CPUPlace
()
trainer
=
fluid
.
Trainer
(
train_func
=
train_program
,
optimizer
=
fluid
.
optimizer
.
Adam
(
learning_rate
=
0.001
),
place
=
place
)
train_func
=
train_program
,
optimizer_func
=
optimizer_func
,
place
=
place
)
trainer
.
train
(
reader
=
train_reader
,
...
...
python/paddle/fluid/tests/book/high-level-api/image_classification/test_image_classification_vgg.py
浏览文件 @
99a5a3d8
...
...
@@ -64,6 +64,10 @@ def train_network():
return
[
avg_cost
,
accuracy
]
def
optimizer_func
():
return
fluid
.
optimizer
.
Adam
(
learning_rate
=
0.001
)
def
train
(
use_cuda
,
train_program
,
params_dirname
):
BATCH_SIZE
=
128
train_reader
=
paddle
.
batch
(
...
...
@@ -88,9 +92,7 @@ def train(use_cuda, train_program, params_dirname):
place
=
fluid
.
CUDAPlace
(
0
)
if
use_cuda
else
fluid
.
CPUPlace
()
trainer
=
fluid
.
Trainer
(
train_func
=
train_program
,
place
=
place
,
optimizer
=
fluid
.
optimizer
.
Adam
(
learning_rate
=
0.001
))
train_func
=
train_program
,
place
=
place
,
optimizer_func
=
optimizer_func
)
trainer
.
train
(
reader
=
train_reader
,
...
...
python/paddle/fluid/tests/book/high-level-api/machine_translation/test_machine_translation.py
浏览文件 @
99a5a3d8
...
...
@@ -158,6 +158,13 @@ def train_program(is_sparse):
return
avg_cost
def
optimizer_func
():
return
fluid
.
optimizer
.
Adagrad
(
learning_rate
=
1e-4
,
regularization
=
fluid
.
regularizer
.
L2DecayRegularizer
(
regularization_coeff
=
0.1
))
def
train
(
use_cuda
,
is_sparse
,
is_local
=
True
):
EPOCH_NUM
=
1
...
...
@@ -182,11 +189,8 @@ def train(use_cuda, is_sparse, is_local=True):
trainer
=
fluid
.
Trainer
(
train_func
=
partial
(
train_program
,
is_sparse
),
optimizer
=
fluid
.
optimizer
.
Adagrad
(
learning_rate
=
1e-4
,
regularization
=
fluid
.
regularizer
.
L2DecayRegularizer
(
regularization_coeff
=
0.1
)),
place
=
place
)
place
=
place
,
optimizer_func
=
optimizer_func
)
trainer
.
train
(
reader
=
train_reader
,
...
...
python/paddle/fluid/tests/book/high-level-api/recognize_digits/test_recognize_digits_conv.py
浏览文件 @
99a5a3d8
...
...
@@ -57,14 +57,17 @@ def train_program():
return
[
avg_cost
,
acc
]
def
optimizer_func
():
return
fluid
.
optimizer
.
Adam
(
learning_rate
=
0.001
)
def
train
(
use_cuda
,
train_program
,
params_dirname
):
place
=
fluid
.
CUDAPlace
(
0
)
if
use_cuda
else
fluid
.
CPUPlace
()
optimizer
=
fluid
.
optimizer
.
Adam
(
learning_rate
=
0.001
)
trainer
=
fluid
.
Trainer
(
train_func
=
train_program
,
place
=
place
,
optimizer
=
optimizer
,
optimizer
_func
=
optimizer_func
,
parallel
=
True
)
def
event_handler
(
event
):
...
...
python/paddle/fluid/tests/book/high-level-api/recognize_digits/test_recognize_digits_mlp.py
浏览文件 @
99a5a3d8
...
...
@@ -44,12 +44,15 @@ def train_program():
return
[
avg_cost
,
acc
]
def
optimizer_func
():
return
fluid
.
optimizer
.
Adam
(
learning_rate
=
0.001
)
def
train
(
use_cuda
,
train_program
,
params_dirname
):
place
=
fluid
.
CUDAPlace
(
0
)
if
use_cuda
else
fluid
.
CPUPlace
()
optimizer
=
fluid
.
optimizer
.
Adam
(
learning_rate
=
0.001
)
trainer
=
fluid
.
Trainer
(
train_func
=
train_program
,
place
=
place
,
optimizer
=
optimizer
)
train_func
=
train_program
,
place
=
place
,
optimizer
_func
=
optimizer_func
)
def
event_handler
(
event
):
if
isinstance
(
event
,
fluid
.
EndEpochEvent
):
...
...
python/paddle/fluid/tests/book/high-level-api/recommender_system/test_recommender_system_newapi.py
浏览文件 @
99a5a3d8
...
...
@@ -155,12 +155,15 @@ def train_program():
return
[
avg_cost
,
scale_infer
]
def
optimizer_func
():
return
fluid
.
optimizer
.
SGD
(
learning_rate
=
0.2
)
def
train
(
use_cuda
,
train_program
,
params_dirname
):
place
=
fluid
.
CUDAPlace
(
0
)
if
use_cuda
else
fluid
.
CPUPlace
()
optimizer
=
fluid
.
optimizer
.
SGD
(
learning_rate
=
0.2
)
trainer
=
fluid
.
Trainer
(
train_func
=
train_program
,
place
=
place
,
optimizer
=
optimizer
)
train_func
=
train_program
,
place
=
place
,
optimizer
_func
=
optimizer_func
)
feed_order
=
[
'user_id'
,
'gender_id'
,
'age_id'
,
'job_id'
,
'movie_id'
,
'category_id'
,
...
...
python/paddle/fluid/tests/book/high-level-api/understand_sentiment/test_understand_sentiment_conv.py
浏览文件 @
99a5a3d8
...
...
@@ -64,15 +64,18 @@ def train_program(word_dict):
return
[
avg_cost
,
accuracy
]
def
optimizer_func
():
return
fluid
.
optimizer
.
Adagrad
(
learning_rate
=
0.002
)
def
train
(
use_cuda
,
train_program
,
params_dirname
):
place
=
fluid
.
CUDAPlace
(
0
)
if
use_cuda
else
fluid
.
CPUPlace
()
optimizer
=
fluid
.
optimizer
.
Adagrad
(
learning_rate
=
0.002
)
word_dict
=
paddle
.
dataset
.
imdb
.
word_dict
()
trainer
=
fluid
.
Trainer
(
train_func
=
partial
(
train_program
,
word_dict
),
place
=
place
,
optimizer
=
optimizer
)
optimizer
_func
=
optimizer_func
)
def
event_handler
(
event
):
if
isinstance
(
event
,
fluid
.
EndEpochEvent
):
...
...
python/paddle/fluid/tests/book/high-level-api/understand_sentiment/test_understand_sentiment_dynamic_rnn.py
浏览文件 @
99a5a3d8
...
...
@@ -79,15 +79,18 @@ def train_program(word_dict):
return
[
avg_cost
,
accuracy
]
def
optimizer_func
():
return
fluid
.
optimizer
.
Adagrad
(
learning_rate
=
0.002
)
def
train
(
use_cuda
,
train_program
,
params_dirname
):
place
=
fluid
.
CUDAPlace
(
0
)
if
use_cuda
else
fluid
.
CPUPlace
()
optimizer
=
fluid
.
optimizer
.
Adagrad
(
learning_rate
=
0.002
)
word_dict
=
paddle
.
dataset
.
imdb
.
word_dict
()
trainer
=
fluid
.
Trainer
(
train_func
=
partial
(
train_program
,
word_dict
),
place
=
place
,
optimizer
=
optimizer
)
optimizer
_func
=
optimizer_func
)
def
event_handler
(
event
):
if
isinstance
(
event
,
fluid
.
EndEpochEvent
):
...
...
python/paddle/fluid/tests/book/high-level-api/understand_sentiment/test_understand_sentiment_stacked_lstm.py
浏览文件 @
99a5a3d8
...
...
@@ -71,15 +71,18 @@ def train_program(word_dict):
return
[
avg_cost
,
accuracy
]
def
optimizer_func
():
return
fluid
.
optimizer
.
Adagrad
(
learning_rate
=
0.002
)
def
train
(
use_cuda
,
train_program
,
params_dirname
):
place
=
fluid
.
CUDAPlace
(
0
)
if
use_cuda
else
fluid
.
CPUPlace
()
optimizer
=
fluid
.
optimizer
.
Adagrad
(
learning_rate
=
0.002
)
word_dict
=
paddle
.
dataset
.
imdb
.
word_dict
()
trainer
=
fluid
.
Trainer
(
train_func
=
partial
(
train_program
,
word_dict
),
place
=
place
,
optimizer
=
optimizer
)
optimizer
_func
=
optimizer_func
)
def
event_handler
(
event
):
if
isinstance
(
event
,
fluid
.
EndEpochEvent
):
...
...
python/paddle/fluid/tests/book/high-level-api/word2vec/test_word2vec_new_api.py
浏览文件 @
99a5a3d8
...
...
@@ -80,6 +80,10 @@ def train_program(is_sparse):
return
avg_cost
def
optimizer_func
():
return
fluid
.
optimizer
.
SGD
(
learning_rate
=
0.001
)
def
train
(
use_cuda
,
train_program
,
params_dirname
):
train_reader
=
paddle
.
batch
(
paddle
.
dataset
.
imikolov
.
train
(
word_dict
,
N
),
BATCH_SIZE
)
...
...
@@ -104,9 +108,7 @@ def train(use_cuda, train_program, params_dirname):
sys
.
exit
(
"got NaN loss, training failed."
)
trainer
=
fluid
.
Trainer
(
train_func
=
train_program
,
optimizer
=
fluid
.
optimizer
.
SGD
(
learning_rate
=
0.001
),
place
=
place
)
train_func
=
train_program
,
optimizer_func
=
optimizer_func
,
place
=
place
)
trainer
.
train
(
reader
=
train_reader
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录