Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
PaddleRec
提交
fb47984d
P
PaddleRec
项目概览
BaiXuePrincess
/
PaddleRec
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleRec
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleRec
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
fb47984d
编写于
6月 02, 2020
作者:
M
malin10
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
code style
上级
1aa218f3
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
7 addition
and
8 deletion
+7
-8
models/recall/fasttext/model.py
models/recall/fasttext/model.py
+4
-4
models/recall/fasttext/preprocess.py
models/recall/fasttext/preprocess.py
+3
-4
未找到文件。
models/recall/fasttext/model.py
浏览文件 @
fb47984d
...
...
@@ -130,8 +130,8 @@ class Model(ModelBase):
loss
=
fluid
.
layers
.
log_loss
(
fluid
.
layers
.
sigmoid
(
logits
),
label
)
avg_cost
=
fluid
.
layers
.
reduce_sum
(
loss
)
global_right_cnt
=
fluid
.
layers
.
create_global_var
(
global_right_cnt
=
fluid
.
layers
.
create_global_var
(
name
=
"global_right_cnt"
,
persistable
=
True
,
dtype
=
'float32'
,
...
...
@@ -144,7 +144,7 @@ class Model(ModelBase):
shape
=
[
1
],
value
=
0
)
global_right_cnt
.
stop_gradient
=
True
global_total_cnt
.
stop_gradient
=
True
global_total_cnt
.
stop_gradient
=
True
self
.
_cost
=
avg_cost
self
.
_metrics
[
"LOSS"
]
=
avg_cost
...
...
@@ -211,7 +211,7 @@ class Model(ModelBase):
tmp1
=
fluid
.
layers
.
elementwise_add
(
right_cnt
,
global_right_cnt
)
fluid
.
layers
.
assign
(
tmp1
,
global_right_cnt
)
tmp2
=
fluid
.
layers
.
elementwise_add
(
total_cnt
,
global_total_cnt
)
fluid
.
layers
.
assign
(
tmp2
,
global_total_cnt
)
...
...
models/recall/fasttext/preprocess.py
浏览文件 @
fb47984d
...
...
@@ -50,8 +50,8 @@ def parse_args():
default
=
'./word_ngrams'
,
help
=
"The path of word_ngrams "
)
parser
.
add_argument
(
'--ngrams_id_path'
,
type
=
str
,
'--ngrams_id_path'
,
type
=
str
,
default
=
'./word_ngrams_id'
,
help
=
"The path of word_ngrams_id "
)
parser
.
add_argument
(
...
...
@@ -157,8 +157,7 @@ def filter_corpus(args):
# write word2id file
print
(
"write word2id file to : "
+
args
.
dict_path
+
"_word_to_id_"
)
with
io
.
open
(
args
.
word_id_path
,
'w+'
,
encoding
=
'utf-8'
)
as
fid
:
with
io
.
open
(
args
.
word_id_path
,
'w+'
,
encoding
=
'utf-8'
)
as
fid
:
for
k
,
v
in
word_to_id_
.
items
():
fid
.
write
(
k
+
" "
+
str
(
v
)
+
'
\n
'
)
# filter corpus and convert id
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录