Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
book
提交
a2702e5f
B
book
项目概览
PaddlePaddle
/
book
通知
16
Star
4
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
40
列表
看板
标记
里程碑
合并请求
37
Wiki
5
Wiki
分析
仓库
DevOps
项目成员
Pages
B
book
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
40
Issue
40
列表
看板
标记
里程碑
合并请求
37
合并请求
37
Pages
分析
分析
仓库分析
DevOps
Wiki
5
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a2702e5f
编写于
7月 17, 2018
作者:
D
daming-lu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test on cluster
上级
d4414cbb
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
54 addition
and
8 deletion
+54
-8
06.understand_sentiment/train_conv.py
06.understand_sentiment/train_conv.py
+20
-2
06.understand_sentiment/train_dyn_rnn.py
06.understand_sentiment/train_dyn_rnn.py
+17
-3
06.understand_sentiment/train_stacked_lstm.py
06.understand_sentiment/train_stacked_lstm.py
+17
-3
未找到文件。
06.understand_sentiment/train_conv.py
浏览文件 @
a2702e5f
...
...
@@ -14,6 +14,10 @@
from
__future__
import
print_function
import
time
start
=
time
.
time
()
import
os
import
paddle
import
paddle.fluid
as
fluid
...
...
@@ -133,8 +137,16 @@ def infer(use_cuda, inference_program, params_dirname=None):
# Note that lod info should be a list of lists.
reviews_str
=
[
'read the book forget the movie'
,
'this is a great movie'
,
'this is very bad'
'read the book forget the movie'
,
'this is a great movie'
,
'this is very bad'
,
'the movie makes me sick'
,
'you can never find a worse movie'
,
'what a masterpiece'
,
'it deserves any compliment'
,
'no movie this year could be better than this one'
,
'i would rather die'
,
'the movie should be burned in hell'
]
reviews
=
[
c
.
split
()
for
c
in
reviews_str
]
...
...
@@ -157,10 +169,16 @@ def main(use_cuda):
if
use_cuda
and
not
fluid
.
core
.
is_compiled_with_cuda
():
return
params_dirname
=
"understand_sentiment_conv.inference.model"
import
pdb
;
pdb
.
set_trace
()
train
(
use_cuda
,
train_program
,
params_dirname
)
infer
(
use_cuda
,
inference_program
,
params_dirname
)
finish
=
time
.
time
()
elapsed
=
finish
-
start
print
(
elapsed
)
if
__name__
==
'__main__'
:
use_cuda
=
False
# set to True if training with GPU
main
(
use_cuda
)
06.understand_sentiment/train_dyn_rnn.py
浏览文件 @
a2702e5f
...
...
@@ -14,6 +14,9 @@
from
__future__
import
print_function
import
time
start
=
time
.
time
()
import
os
import
paddle
import
paddle.fluid
as
fluid
...
...
@@ -123,7 +126,7 @@ def train(use_cuda, train_program, params_dirname):
trainer
.
save_params
(
params_dirname
)
trainer
.
train
(
num_epochs
=
1
,
num_epochs
=
2
,
event_handler
=
event_handler
,
reader
=
train_reader
,
feed_order
=
feed_order
)
...
...
@@ -150,8 +153,16 @@ def infer(use_cuda, inference_program, params_dirname=None):
# Note that lod info should be a list of lists.
reviews_str
=
[
'read the book forget the movie'
,
'this is a great movie'
,
'this is very bad'
'read the book forget the movie'
,
'this is a great movie'
,
'this is very bad'
,
'the movie makes me sick'
,
'you can never find a worse movie'
,
'what a masterpiece'
,
'it deserves any compliment'
,
'no movie this year could be better than this one'
,
'i would rather die'
,
'the movie should be burned in hell'
]
reviews
=
[
c
.
split
()
for
c
in
reviews_str
]
...
...
@@ -177,6 +188,9 @@ def main(use_cuda):
train
(
use_cuda
,
train_program
,
params_dirname
)
infer
(
use_cuda
,
inference_program
,
params_dirname
)
finish
=
time
.
time
()
elapsed
=
finish
-
start
print
(
elapsed
)
if
__name__
==
'__main__'
:
use_cuda
=
False
# set to True if training with GPU
...
...
06.understand_sentiment/train_stacked_lstm.py
浏览文件 @
a2702e5f
...
...
@@ -14,6 +14,9 @@
from
__future__
import
print_function
import
time
start
=
time
.
time
()
import
os
import
paddle
import
paddle.fluid
as
fluid
...
...
@@ -114,7 +117,7 @@ def train(use_cuda, train_program, params_dirname):
trainer
.
save_params
(
params_dirname
)
trainer
.
train
(
num_epochs
=
1
,
num_epochs
=
4
,
event_handler
=
event_handler
,
reader
=
train_reader
,
feed_order
=
feed_order
)
...
...
@@ -141,8 +144,16 @@ def infer(use_cuda, inference_program, params_dirname=None):
# Note that lod info should be a list of lists.
reviews_str
=
[
'read the book forget the movie'
,
'this is a great movie'
,
'this is very bad'
'read the book forget the movie'
,
'this is a great movie'
,
'this is very bad'
,
'the movie makes me sick'
,
'you can never find a worse movie'
,
'what a masterpiece'
,
'it deserves any compliment'
,
'no movie this year could be better than this one'
,
'i would rather die'
,
'the movie should be burned in hell'
]
reviews
=
[
c
.
split
()
for
c
in
reviews_str
]
...
...
@@ -168,6 +179,9 @@ def main(use_cuda):
train
(
use_cuda
,
train_program
,
params_dirname
)
infer
(
use_cuda
,
inference_program
,
params_dirname
)
finish
=
time
.
time
()
elapsed
=
finish
-
start
print
(
elapsed
)
if
__name__
==
'__main__'
:
use_cuda
=
False
# set to True if training with GPU
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录