Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
69485cf3
S
Serving
项目概览
PaddlePaddle
/
Serving
大约 1 年 前同步成功
通知
186
Star
833
Fork
253
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
105
列表
看板
标记
里程碑
合并请求
10
Wiki
2
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Serving
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
105
Issue
105
列表
看板
标记
里程碑
合并请求
10
合并请求
10
Pages
分析
分析
仓库分析
DevOps
Wiki
2
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
69485cf3
编写于
11月 14, 2019
作者:
W
wangguibao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
elastic CTR
上级
f4e0f803
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
20 addition
and
6 deletion
+20
-6
elastic-ctr/client/demo/elastic_ctr.py
elastic-ctr/client/demo/elastic_ctr.py
+20
-6
未找到文件。
elastic-ctr/client/demo/elastic_ctr.py
浏览文件 @
69485cf3
...
@@ -14,7 +14,6 @@
...
@@ -14,7 +14,6 @@
from
__future__
import
print_function
from
__future__
import
print_function
import
json
import
json
import
httplib
import
sys
import
sys
import
os
import
os
...
@@ -27,6 +26,13 @@ CTR_EMBEDDING_TABLE_SIZE = 400000001
...
@@ -27,6 +26,13 @@ CTR_EMBEDDING_TABLE_SIZE = 400000001
SLOTS
=
[]
SLOTS
=
[]
def
str2long
(
str
):
if
sys
.
version_info
[
0
]
==
2
:
return
long
(
str
)
elif
sys
.
version_info
[
0
]
==
3
:
return
int
(
str
)
def
data_reader
(
data_file
,
samples
,
labels
):
def
data_reader
(
data_file
,
samples
,
labels
):
if
not
os
.
path
.
exists
(
data_file
):
if
not
os
.
path
.
exists
(
data_file
):
print
(
"Path %s not exist"
%
data_file
)
print
(
"Path %s not exist"
%
data_file
)
...
@@ -45,10 +51,14 @@ def data_reader(data_file, samples, labels):
...
@@ -45,10 +51,14 @@ def data_reader(data_file, samples, labels):
for
i
in
range
(
0
,
len
(
features
)):
for
i
in
range
(
0
,
len
(
features
)):
if
slots
[
i
]
in
sample
:
if
slots
[
i
]
in
sample
:
sample
[
slots
[
i
]]
=
[
sample
[
slots
[
i
]]
+
long
(
features
[
i
])]
sample
[
slots
[
i
]]
=
[
sample
[
slots
[
i
]]
+
str2long
(
features
[
i
])
%
CTR_EMBEDDING_TABLE_SIZE
]
else
:
else
:
sample
[
slots
[
sample
[
slots
[
i
]]
=
[
i
]]
=
[
long
(
features
[
i
])
%
CTR_EMBEDDING_TABLE_SIZE
]
str2long
(
features
[
i
])
%
CTR_EMBEDDING_TABLE_SIZE
]
for
x
in
SLOTS
:
for
x
in
SLOTS
:
if
not
x
in
sample
:
if
not
x
in
sample
:
...
@@ -85,8 +95,12 @@ if __name__ == "__main__":
...
@@ -85,8 +95,12 @@ if __name__ == "__main__":
for
sample
in
batch
:
for
sample
in
batch
:
instance
=
api
.
add_instance
()
instance
=
api
.
add_instance
()
kv
=
[]
kv
=
[]
for
k
,
v
in
sample
.
iteritems
():
if
sys
.
version_info
[
0
]
==
2
:
api
.
add_slot
(
instance
,
k
,
v
)
for
k
,
v
in
sample
.
iteritems
():
api
.
add_slot
(
instance
,
k
,
v
)
elif
sys
.
version_info
[
0
]
==
3
:
for
k
,
v
in
sample
.
items
():
api
.
add_slot
(
instance
,
k
,
v
)
ret
=
api
.
inference
()
ret
=
api
.
inference
()
print
(
ret
)
print
(
ret
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录