Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
4946f5f5
M
models
项目概览
PaddlePaddle
/
models
大约 1 年 前同步成功
通知
222
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看板
提交
4946f5f5
编写于
1月 09, 2019
作者:
J
JiabinYang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
for test w2v on small
上级
b8555a93
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
38 addition
and
31 deletion
+38
-31
fluid/PaddleRec/word2vec/async_train.py
fluid/PaddleRec/word2vec/async_train.py
+1
-1
fluid/PaddleRec/word2vec/infer.py
fluid/PaddleRec/word2vec/infer.py
+1
-1
fluid/PaddleRec/word2vec/preprocess.py
fluid/PaddleRec/word2vec/preprocess.py
+35
-29
fluid/PaddleRec/word2vec/train.py
fluid/PaddleRec/word2vec/train.py
+1
-0
未找到文件。
fluid/PaddleRec/word2vec/async_train.py
浏览文件 @
4946f5f5
...
...
@@ -164,7 +164,7 @@ def async_train_loop(args, train_program, dataset, loss, thread_num):
debug
=
False
)
epoch_stop
=
time
.
time
()
run_time
=
epoch_stop
-
epoch_start
lines
=
len
(
filelist
)
*
1000000.0
lines
=
109984625
print
(
"run epoch%d done, lines=%s, time=%d, sample/second=%s"
%
(
i
+
1
,
lines
,
run_time
,
lines
/
run_time
))
epoch_model
=
"word2vec_model/epoch"
+
str
(
i
+
1
)
...
...
fluid/PaddleRec/word2vec/infer.py
浏览文件 @
4946f5f5
...
...
@@ -59,7 +59,7 @@ def parse_args():
parser
.
add_argument
(
'--test_batch_size'
,
type
=
int
,
default
=
100
0
,
default
=
100
,
help
=
"test used batch size (default: 1000)"
)
return
parser
.
parse_args
()
...
...
fluid/PaddleRec/word2vec/preprocess.py
浏览文件 @
4946f5f5
...
...
@@ -198,10 +198,10 @@ def preprocess(args):
"""
# word to count
if
args
.
with_other_dict
:
with
io
.
open
(
args
.
other_dict_path
,
'r'
,
encoding
=
'utf-8'
)
as
f
:
for
line
in
f
:
word_count
[
native_to_unicode
(
line
.
strip
())]
=
1
#
if args.with_other_dict:
#
with io.open(args.other_dict_path, 'r', encoding='utf-8') as f:
#
for line in f:
#
word_count[native_to_unicode(line.strip())] = 1
# if args.is_local:
# for i in range(1, 100):
...
...
@@ -223,31 +223,37 @@ def preprocess(args):
# word_count[item] = word_count[item] + 1
# else:
# word_count[item] = 1
if
args
.
is_local
:
with
io
.
open
(
args
.
data_path
+
"/text8"
,
encoding
=
'utf-8'
)
as
f
:
for
line
in
f
:
if
args
.
with_other_dict
:
line
=
strip_lines
(
line
)
words
=
line
.
split
()
for
item
in
words
:
if
item
in
word_count
:
word_count
[
item
]
=
word_count
[
item
]
+
1
else
:
word_count
[
native_to_unicode
(
'<UNK>'
)]
+=
1
else
:
line
=
text_strip
(
line
)
words
=
line
.
split
()
for
item
in
words
:
if
item
in
word_count
:
word_count
[
item
]
=
word_count
[
item
]
+
1
else
:
word_count
[
item
]
=
1
item_to_remove
=
[]
for
item
in
word_count
:
if
word_count
[
item
]
<=
args
.
freq
:
item_to_remove
.
append
(
item
)
for
item
in
item_to_remove
:
del
word_count
[
item
]
# if args.is_local:
# with io.open(args.data_path + "/text8", encoding='utf-8') as f:
# for line in f:
# if args.with_other_dict:
# line = strip_lines(line)
# words = line.split()
# for item in words:
# if item in word_count:
# word_count[item] = word_count[item] + 1
# else:
# word_count[native_to_unicode('<UNK>')] += 1
# else:
# line = text_strip(line)
# words = line.split()
# for item in words:
# if item in word_count:
# word_count[item] = word_count[item] + 1
# else:
# word_count[item] = 1
# item_to_remove = []
# for item in word_count:
# if word_count[item] <= args.freq:
# item_to_remove.append(item)
# for item in item_to_remove:
# del word_count[item]
with
io
.
open
(
args
.
dict_path
,
'r'
,
encoding
=
'utf-8'
)
as
f
:
for
line
in
f
:
word
,
count
=
line
.
split
()[
0
],
int
(
line
.
split
()[
1
])
word_count
[
word
]
=
count
print
(
word_count
)
path_table
,
path_code
,
word_code_len
=
build_Huffman
(
word_count
,
40
)
...
...
fluid/PaddleRec/word2vec/train.py
浏览文件 @
4946f5f5
...
...
@@ -141,6 +141,7 @@ def convert_python_to_tensor(batch_size, sample_reader, is_hs):
result
=
[[],
[]]
for
sample
in
sample_reader
():
for
i
,
fea
in
enumerate
(
sample
):
print
(
fea
)
result
[
i
].
append
(
fea
)
if
len
(
result
[
0
])
==
batch_size
:
tensor_result
=
[]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录