Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
b74a5918
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
b74a5918
编写于
5月 05, 2019
作者:
Y
Yibing Liu
提交者:
GitHub
5月 05, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix core.xxx usage in rec (#2180)
上级
e64bd9c4
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
69 addition
and
38 deletion
+69
-38
PaddleRec/ctr/infer.py
PaddleRec/ctr/infer.py
+17
-14
PaddleRec/din/infer.py
PaddleRec/din/infer.py
+9
-3
PaddleRec/gru4rec/infer.py
PaddleRec/gru4rec/infer.py
+1
-1
PaddleRec/gru4rec/infer_sample_neg.py
PaddleRec/gru4rec/infer_sample_neg.py
+1
-1
PaddleRec/multiview_simnet/infer.py
PaddleRec/multiview_simnet/infer.py
+37
-15
PaddleRec/ssr/infer.py
PaddleRec/ssr/infer.py
+1
-1
PaddleRec/tagspace/infer.py
PaddleRec/tagspace/infer.py
+1
-1
PaddleRec/word2vec/infer.py
PaddleRec/word2vec/infer.py
+2
-2
未找到文件。
PaddleRec/ctr/infer.py
浏览文件 @
b74a5918
...
...
@@ -11,9 +11,7 @@ import paddle.fluid as fluid
import
reader
from
network_conf
import
ctr_dnn_model
logging
.
basicConfig
(
format
=
'%(asctime)s - %(levelname)s - %(message)s'
)
logging
.
basicConfig
(
format
=
'%(asctime)s - %(levelname)s - %(message)s'
)
logger
=
logging
.
getLogger
(
"fluid"
)
logger
.
setLevel
(
logging
.
INFO
)
...
...
@@ -53,21 +51,25 @@ def infer():
args
=
parse_args
()
place
=
fluid
.
CPUPlace
()
inference_scope
=
fluid
.
core
.
Scope
()
inference_scope
=
fluid
.
Scope
()
dataset
=
reader
.
CriteoDataset
(
args
.
sparse_feature_dim
)
test_reader
=
paddle
.
batch
(
dataset
.
test
([
args
.
data_path
]),
batch_size
=
args
.
batch_size
)
test_reader
=
paddle
.
batch
(
dataset
.
test
([
args
.
data_path
]),
batch_size
=
args
.
batch_size
)
startup_program
=
fluid
.
framework
.
Program
()
test_program
=
fluid
.
framework
.
Program
()
with
fluid
.
framework
.
program_guard
(
test_program
,
startup_program
):
loss
,
auc_var
,
batch_auc_var
,
_
,
data_list
=
ctr_dnn_model
(
args
.
embedding_size
,
args
.
sparse_feature_dim
,
False
)
loss
,
auc_var
,
batch_auc_var
,
_
,
data_list
=
ctr_dnn_model
(
args
.
embedding_size
,
args
.
sparse_feature_dim
,
False
)
exe
=
fluid
.
Executor
(
place
)
feeder
=
fluid
.
DataFeeder
(
feed_list
=
data_list
,
place
=
place
)
fluid
.
io
.
load_persistables
(
executor
=
exe
,
dirname
=
args
.
model_path
,
fluid
.
io
.
load_persistables
(
executor
=
exe
,
dirname
=
args
.
model_path
,
main_program
=
fluid
.
default_main_program
())
def
set_zero
(
var_name
):
...
...
@@ -84,7 +86,8 @@ def infer():
feed
=
feeder
.
feed
(
data
),
fetch_list
=
[
loss
,
auc_var
])
if
batch_id
%
100
==
0
:
logger
.
info
(
"TEST --> batch: {} loss: {} auc: {}"
.
format
(
batch_id
,
loss_val
/
args
.
batch_size
,
auc_val
))
logger
.
info
(
"TEST --> batch: {} loss: {} auc: {}"
.
format
(
batch_id
,
loss_val
/
args
.
batch_size
,
auc_val
))
if
__name__
==
'__main__'
:
...
...
PaddleRec/din/infer.py
浏览文件 @
b74a5918
...
...
@@ -28,9 +28,15 @@ logger.setLevel(logging.INFO)
def
parse_args
():
parser
=
argparse
.
ArgumentParser
(
description
=
"PaddlePaddle DIN example"
)
parser
.
add_argument
(
'--model_path'
,
type
=
str
,
required
=
True
,
help
=
"path of model parameters"
)
'--model_path'
,
type
=
str
,
required
=
True
,
help
=
"path of model parameters"
)
parser
.
add_argument
(
'--test_path'
,
type
=
str
,
default
=
'data/paddle_test.txt.bak'
,
help
=
'dir of test file'
)
'--test_path'
,
type
=
str
,
default
=
'data/paddle_test.txt.bak'
,
help
=
'dir of test file'
)
parser
.
add_argument
(
'--use_cuda'
,
type
=
int
,
default
=
0
,
help
=
'whether to use gpu'
)
...
...
@@ -64,7 +70,7 @@ def infer():
data_reader
,
_
=
reader
.
prepare_reader
(
args
.
test_path
,
32
*
16
)
place
=
fluid
.
CUDAPlace
(
0
)
if
use_cuda
else
fluid
.
CPUPlace
()
inference_scope
=
fluid
.
core
.
Scope
()
inference_scope
=
fluid
.
Scope
()
exe
=
fluid
.
Executor
(
place
)
...
...
PaddleRec/gru4rec/infer.py
浏览文件 @
b74a5918
...
...
@@ -37,7 +37,7 @@ def infer(test_reader, use_cuda, model_path):
place
=
fluid
.
CUDAPlace
(
0
)
if
use_cuda
else
fluid
.
CPUPlace
()
exe
=
fluid
.
Executor
(
place
)
with
fluid
.
scope_guard
(
fluid
.
core
.
Scope
()):
with
fluid
.
scope_guard
(
fluid
.
Scope
()):
infer_program
,
feed_target_names
,
fetch_vars
=
fluid
.
io
.
load_inference_model
(
model_path
,
exe
)
accum_num_recall
=
0.0
...
...
PaddleRec/gru4rec/infer_sample_neg.py
浏览文件 @
b74a5918
...
...
@@ -40,7 +40,7 @@ def infer(args, vocab_size, test_reader, use_cuda):
exe
=
fluid
.
Executor
(
place
)
hid_size
=
args
.
hid_size
batch_size
=
args
.
batch_size
with
fluid
.
scope_guard
(
fluid
.
core
.
Scope
()):
with
fluid
.
scope_guard
(
fluid
.
Scope
()):
main_program
=
fluid
.
Program
()
with
fluid
.
program_guard
(
main_program
):
acc
=
net
.
infer_network
(
vocab_size
,
batch_size
,
hid_size
)
...
...
PaddleRec/multiview_simnet/infer.py
浏览文件 @
b74a5918
...
...
@@ -33,32 +33,51 @@ logger.setLevel(logging.INFO)
def
parse_args
():
parser
=
argparse
.
ArgumentParser
(
"multi-view simnet"
)
parser
.
add_argument
(
"--train_file"
,
type
=
str
,
help
=
"Training file"
)
parser
.
add_argument
(
"--valid_file"
,
type
=
str
,
help
=
"Validation file"
)
parser
.
add_argument
(
"--train_file"
,
type
=
str
,
help
=
"Training file"
)
parser
.
add_argument
(
"--valid_file"
,
type
=
str
,
help
=
"Validation file"
)
parser
.
add_argument
(
"--epochs"
,
type
=
int
,
default
=
10
,
help
=
"Number of epochs for training"
)
parser
.
add_argument
(
"--model_dir"
,
type
=
str
,
default
=
'model_output'
,
help
=
"Model output folder"
)
"--model_dir"
,
type
=
str
,
default
=
'model_output'
,
help
=
"Model output folder"
)
parser
.
add_argument
(
"--query_slots"
,
type
=
int
,
default
=
1
,
help
=
"Number of query slots"
)
parser
.
add_argument
(
"--title_slots"
,
type
=
int
,
default
=
1
,
help
=
"Number of title slots"
)
parser
.
add_argument
(
"--query_encoder"
,
type
=
str
,
default
=
"bow"
,
help
=
"Encoder module for slot encoding"
)
"--query_encoder"
,
type
=
str
,
default
=
"bow"
,
help
=
"Encoder module for slot encoding"
)
parser
.
add_argument
(
"--title_encoder"
,
type
=
str
,
default
=
"bow"
,
help
=
"Encoder module for slot encoding"
)
"--title_encoder"
,
type
=
str
,
default
=
"bow"
,
help
=
"Encoder module for slot encoding"
)
parser
.
add_argument
(
"--query_encode_dim"
,
type
=
int
,
default
=
128
,
help
=
"Dimension of query encoder output"
)
"--query_encode_dim"
,
type
=
int
,
default
=
128
,
help
=
"Dimension of query encoder output"
)
parser
.
add_argument
(
"--title_encode_dim"
,
type
=
int
,
default
=
128
,
help
=
"Dimension of title encoder output"
)
"--title_encode_dim"
,
type
=
int
,
default
=
128
,
help
=
"Dimension of title encoder output"
)
parser
.
add_argument
(
"--batch_size"
,
type
=
int
,
default
=
128
,
help
=
"Batch size for training"
)
parser
.
add_argument
(
"--embedding_dim"
,
type
=
int
,
default
=
128
,
help
=
"Default Dimension of Embedding"
)
"--embedding_dim"
,
type
=
int
,
default
=
128
,
help
=
"Default Dimension of Embedding"
)
parser
.
add_argument
(
"--sparse_feature_dim"
,
type
=
int
,
default
=
1000001
,
help
=
"Sparse feature hashing space for index processing"
)
"--sparse_feature_dim"
,
type
=
int
,
default
=
1000001
,
help
=
"Sparse feature hashing space for index processing"
)
parser
.
add_argument
(
"--hidden_size"
,
type
=
int
,
default
=
128
,
help
=
"Hidden dim"
)
return
parser
.
parse_args
()
...
...
@@ -74,12 +93,13 @@ def start_infer(args, model_path):
place
=
fluid
.
CPUPlace
()
exe
=
fluid
.
Executor
(
place
)
with
fluid
.
scope_guard
(
fluid
.
core
.
Scope
()):
with
fluid
.
scope_guard
(
fluid
.
Scope
()):
infer_program
,
feed_target_names
,
fetch_vars
=
fluid
.
io
.
load_inference_model
(
args
.
model_dir
,
exe
)
t0
=
time
.
time
()
step_id
=
0
feeder
=
fluid
.
DataFeeder
(
program
=
infer_program
,
feed_list
=
feed_target_names
,
place
=
place
)
feeder
=
fluid
.
DataFeeder
(
program
=
infer_program
,
feed_list
=
feed_target_names
,
place
=
place
)
for
batch_id
,
data
in
enumerate
(
test_reader
()):
step_id
+=
1
loss_val
,
correct_val
=
exe
.
run
(
infer_program
,
...
...
@@ -89,9 +109,11 @@ def start_infer(args, model_path):
.
format
(
step_id
,
batch_id
,
loss_val
,
float
(
correct_val
)
/
args
.
batch_size
))
def
main
():
args
=
parse_args
()
start_infer
(
args
,
args
.
model_dir
)
if
__name__
==
"__main__"
:
main
()
PaddleRec/ssr/infer.py
浏览文件 @
b74a5918
...
...
@@ -76,7 +76,7 @@ def infer(args, vocab_size, test_reader):
hid_size
=
args
.
hid_size
batch_size
=
args
.
batch_size
model_path
=
args
.
model_dir
with
fluid
.
scope_guard
(
fluid
.
core
.
Scope
()):
with
fluid
.
scope_guard
(
fluid
.
Scope
()):
main_program
=
fluid
.
Program
()
start_up_program
=
fluid
.
Program
()
with
fluid
.
program_guard
(
main_program
,
start_up_program
):
...
...
PaddleRec/tagspace/infer.py
浏览文件 @
b74a5918
...
...
@@ -39,7 +39,7 @@ def infer(test_reader, vocab_tag, use_cuda, model_path, epoch):
place
=
fluid
.
CUDAPlace
(
0
)
if
use_cuda
else
fluid
.
CPUPlace
()
exe
=
fluid
.
Executor
(
place
)
with
fluid
.
scope_guard
(
fluid
.
core
.
Scope
()):
with
fluid
.
scope_guard
(
fluid
.
Scope
()):
infer_program
,
feed_target_names
,
fetch_vars
=
fluid
.
io
.
load_inference_model
(
model_path
,
exe
)
t0
=
time
.
time
()
...
...
PaddleRec/word2vec/infer.py
浏览文件 @
b74a5918
...
...
@@ -60,7 +60,7 @@ def infer_epoch(args, vocab_size, test_reader, use_cuda, i2w):
exe
=
fluid
.
Executor
(
place
)
emb_size
=
args
.
emb_size
batch_size
=
args
.
batch_size
with
fluid
.
scope_guard
(
fluid
.
core
.
Scope
()):
with
fluid
.
scope_guard
(
fluid
.
Scope
()):
main_program
=
fluid
.
Program
()
with
fluid
.
program_guard
(
main_program
):
values
,
pred
=
net
.
infer_network
(
vocab_size
,
emb_size
)
...
...
@@ -123,7 +123,7 @@ def infer_step(args, vocab_size, test_reader, use_cuda, i2w):
exe
=
fluid
.
Executor
(
place
)
emb_size
=
args
.
emb_size
batch_size
=
args
.
batch_size
with
fluid
.
scope_guard
(
fluid
.
core
.
Scope
()):
with
fluid
.
scope_guard
(
fluid
.
Scope
()):
main_program
=
fluid
.
Program
()
with
fluid
.
program_guard
(
main_program
):
values
,
pred
=
net
.
infer_network
(
vocab_size
,
emb_size
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录