Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
296b7e3a
M
models
项目概览
PaddlePaddle
/
models
大约 2 年 前同步成功
通知
232
Star
6828
Fork
2962
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
602
列表
看板
标记
里程碑
合并请求
255
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
602
Issue
602
列表
看板
标记
里程碑
合并请求
255
合并请求
255
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
296b7e3a
编写于
12月 05, 2018
作者:
J
JiabinYang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
save model per 1000k batches
上级
b102d256
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
22 addition
and
11 deletion
+22
-11
fluid/PaddleRec/word2vec/infer.py
fluid/PaddleRec/word2vec/infer.py
+4
-4
fluid/PaddleRec/word2vec/reader.py
fluid/PaddleRec/word2vec/reader.py
+10
-0
fluid/PaddleRec/word2vec/train.py
fluid/PaddleRec/word2vec/train.py
+8
-7
未找到文件。
fluid/PaddleRec/word2vec/infer.py
浏览文件 @
296b7e3a
...
...
@@ -135,12 +135,12 @@ def infer_during_train(args):
Scope
=
fluid
.
Scope
()
inference_prog
()
while
True
:
time
.
sleep
(
1
)
time
.
sleep
(
60
)
current_list
=
os
.
listdir
(
args
.
model_output_dir
)
logger
.
info
(
"current_list is : {}"
.
format
(
current_list
))
logger
.
info
(
"model_file_list is : {}"
.
format
(
model_file_list
))
#
logger.info("current_list is : {}".format(current_list))
#
logger.info("model_file_list is : {}".format(model_file_list))
if
set
(
model_file_list
)
==
set
(
current_list
):
logger
.
info
(
"
they are the same
"
)
logger
.
info
(
"
No New models created
"
)
pass
else
:
increment_models
=
list
()
...
...
fluid/PaddleRec/word2vec/reader.py
浏览文件 @
296b7e3a
...
...
@@ -3,6 +3,12 @@
import
numpy
as
np
import
preprocess
import
logging
logging
.
basicConfig
(
format
=
'%(asctime)s - %(levelname)s - %(message)s'
)
logger
=
logging
.
getLogger
(
"fluid"
)
logger
.
setLevel
(
logging
.
INFO
)
class
Word2VecReader
(
object
):
def
__init__
(
self
,
dict_path
,
data_path
,
filelist
,
window_size
=
5
):
...
...
@@ -73,6 +79,8 @@ class Word2VecReader(object):
def
_reader
():
for
file
in
self
.
filelist
:
with
open
(
self
.
data_path_
+
"/"
+
file
,
'r'
)
as
f
:
logger
.
info
(
"running data in {}"
.
format
(
self
.
data_path_
+
"/"
+
file
))
for
line
in
f
:
line
=
preprocess
.
text_strip
(
line
)
word_ids
=
[
...
...
@@ -88,6 +96,8 @@ class Word2VecReader(object):
def
_reader_hs
():
for
file
in
self
.
filelist
:
with
open
(
self
.
data_path_
+
"/"
+
file
,
'r'
)
as
f
:
logger
.
info
(
"running data in {}"
.
format
(
self
.
data_path_
+
"/"
+
file
))
for
line
in
f
:
line
=
preprocess
.
text_strip
(
line
)
word_ids
=
[
...
...
fluid/PaddleRec/word2vec/train.py
浏览文件 @
296b7e3a
...
...
@@ -196,18 +196,19 @@ def train_loop(args, train_program, reader, py_reader, loss, trainer_id):
os
.
getenv
(
"CPU_NUM"
))
logger
.
info
(
"Time used: {}, Samples/Sec: {}"
.
format
(
elapsed
,
samples
/
elapsed
))
if
batch_id
==
200
or
batch_id
==
100
:
model_dir
=
args
.
model_output_dir
+
'/batch-'
+
str
(
batch_id
)
fluid
.
io
.
save_persistables
(
executor
=
exe
,
dirname
=
model_dir
)
with
open
(
model_dir
+
"/_success"
,
'w+'
)
as
f
:
f
.
write
(
str
(
batch_id
))
# calculate infer result each 100 batches
# calculate infer result each 100 batches when using --with_infer_test
if
args
.
with_infer_test
:
if
batch_id
%
1000
==
0
and
batch_id
!=
0
:
model_dir
=
args
.
model_output_dir
+
'/batch-'
+
str
(
batch_id
)
inference_test
(
global_scope
(),
model_dir
,
args
)
if
batch_id
%
100000
==
0
and
batch_id
!=
0
:
model_dir
=
args
.
model_output_dir
+
'/batch-'
+
str
(
batch_id
)
fluid
.
io
.
save_persistables
(
executor
=
exe
,
dirname
=
model_dir
)
with
open
(
model_dir
+
"/_success"
,
'w+'
)
as
f
:
f
.
write
(
str
(
batch_id
))
batch_id
+=
1
except
fluid
.
core
.
EOFException
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录