Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
e3893556
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看板
未验证
提交
e3893556
编写于
11月 22, 2019
作者:
W
Wang Guibao
提交者:
GitHub
11月 22, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #103 from wangguibao/elastic_ctr
Elastic ctr
上级
18eece8d
7f668ee6
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
27 addition
and
4 deletion
+27
-4
elastic-ctr/client/api/python/elasticctr/elastic_ctr_api.py
elastic-ctr/client/api/python/elasticctr/elastic_ctr_api.py
+3
-0
elastic-ctr/client/demo/demo.cpp
elastic-ctr/client/demo/demo.cpp
+1
-1
elastic-ctr/client/demo/elastic_ctr.py
elastic-ctr/client/demo/elastic_ctr.py
+23
-3
未找到文件。
elastic-ctr/client/api/python/elasticctr/elastic_ctr_api.py
浏览文件 @
e3893556
...
@@ -50,6 +50,9 @@ class ElasticCTRAPI(object):
...
@@ -50,6 +50,9 @@ class ElasticCTRAPI(object):
self
.
_instances
+=
instance
self
.
_instances
+=
instance
return
instance
return
instance
def
clear
(
self
):
self
.
_instances
=
[]
def
add_slot
(
self
,
instance
,
slot
,
feasigns
):
def
add_slot
(
self
,
instance
,
slot
,
feasigns
):
if
not
isinstance
(
instance
,
list
):
if
not
isinstance
(
instance
,
list
):
print
(
"add slot: parameter invalid: instance should be list"
)
print
(
"add slot: parameter invalid: instance should be list"
)
...
...
elastic-ctr/client/demo/demo.cpp
浏览文件 @
e3893556
...
@@ -30,7 +30,7 @@ DEFINE_int32(batch_size, 10, "Infernce batch_size");
...
@@ -30,7 +30,7 @@ DEFINE_int32(batch_size, 10, "Infernce batch_size");
DEFINE_string
(
test_file
,
""
,
"test file"
);
DEFINE_string
(
test_file
,
""
,
"test file"
);
const
int
VARIABLE_NAME_LEN
=
256
;
const
int
VARIABLE_NAME_LEN
=
256
;
const
int
CTR_EMBEDDING_TABLE_SIZE
=
4
00000001
;
const
int
CTR_EMBEDDING_TABLE_SIZE
=
1
00000001
;
struct
Sample
{
struct
Sample
{
std
::
map
<
std
::
string
,
std
::
vector
<
uint64_t
>>
slots
;
std
::
map
<
std
::
string
,
std
::
vector
<
uint64_t
>>
slots
;
...
...
elastic-ctr/client/demo/elastic_ctr.py
浏览文件 @
e3893556
...
@@ -22,7 +22,7 @@ from elastic_ctr_api import ElasticCTRAPI
...
@@ -22,7 +22,7 @@ from elastic_ctr_api import ElasticCTRAPI
BATCH_SIZE
=
3
BATCH_SIZE
=
3
SERVING_IP
=
"127.0.0.1"
SERVING_IP
=
"127.0.0.1"
SLOT_CONF_FILE
=
"./conf/slot.conf"
SLOT_CONF_FILE
=
"./conf/slot.conf"
CTR_EMBEDDING_TABLE_SIZE
=
4
00000001
CTR_EMBEDDING_TABLE_SIZE
=
1
00000001
SLOTS
=
[]
SLOTS
=
[]
...
@@ -43,6 +43,7 @@ def data_reader(data_file, samples, labels):
...
@@ -43,6 +43,7 @@ def data_reader(data_file, samples, labels):
sample
=
{}
sample
=
{}
line
=
line
.
rstrip
(
'
\n
'
)
line
=
line
.
rstrip
(
'
\n
'
)
feature_slots
=
line
.
split
(
' '
)
feature_slots
=
line
.
split
(
' '
)
labels
.
append
(
int
(
feature_slots
[
1
]))
feature_slots
=
feature_slots
[
2
:]
feature_slots
=
feature_slots
[
2
:]
feature_slot_maps
=
[
x
.
split
(
':'
)
for
x
in
feature_slots
]
feature_slot_maps
=
[
x
.
split
(
':'
)
for
x
in
feature_slots
]
...
@@ -89,7 +90,9 @@ if __name__ == "__main__":
...
@@ -89,7 +90,9 @@ if __name__ == "__main__":
ret
=
data_reader
(
sys
.
argv
[
4
],
samples
,
labels
)
ret
=
data_reader
(
sys
.
argv
[
4
],
samples
,
labels
)
correct
=
0
for
i
in
range
(
0
,
len
(
samples
)
-
BATCH_SIZE
,
BATCH_SIZE
):
for
i
in
range
(
0
,
len
(
samples
)
-
BATCH_SIZE
,
BATCH_SIZE
):
api
.
clear
()
batch
=
samples
[
i
:
i
+
BATCH_SIZE
]
batch
=
samples
[
i
:
i
+
BATCH_SIZE
]
instances
=
[]
instances
=
[]
for
sample
in
batch
:
for
sample
in
batch
:
...
@@ -102,5 +105,22 @@ if __name__ == "__main__":
...
@@ -102,5 +105,22 @@ if __name__ == "__main__":
api
.
add_slot
(
instance
,
k
,
v
)
api
.
add_slot
(
instance
,
k
,
v
)
ret
=
api
.
inference
()
ret
=
api
.
inference
()
print
(
ret
)
ret
=
json
.
loads
(
ret
)
sys
.
exit
(
0
)
predictions
=
ret
[
"predictions"
]
idx
=
0
for
x
in
predictions
:
if
x
[
"prob0"
]
>=
x
[
"prob1"
]:
pred
=
0
else
:
pred
=
1
if
labels
[
i
+
idx
]
==
pred
:
correct
+=
1
else
:
print
(
"id=%d predict incorrect: pred=%d label=%d (%f %f)"
%
(
i
+
idx
,
pred
,
labels
[
i
+
idx
],
x
[
"prob0"
],
x
[
"prob1"
]))
idx
=
idx
+
1
print
(
"Acc=%f"
%
(
float
(
correct
)
/
len
(
samples
)))
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录