Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
82eb0fe4
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
82eb0fe4
编写于
5月 08, 2017
作者:
D
dzhwinter
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
"fix len type error of QueryList"
上级
16d6bd7c
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
10 addition
and
3 deletion
+10
-3
python/paddle/v2/dataset/mq2007.py
python/paddle/v2/dataset/mq2007.py
+10
-3
未找到文件。
python/paddle/v2/dataset/mq2007.py
浏览文件 @
82eb0fe4
...
@@ -116,6 +116,9 @@ class QueryList(object):
...
@@ -116,6 +116,9 @@ class QueryList(object):
for
query
in
self
.
querylist
:
for
query
in
self
.
querylist
:
yield
query
yield
query
def
__len__
(
self
):
return
len
(
self
.
querylist
)
def
_correct_ranking_
(
self
):
def
_correct_ranking_
(
self
):
if
self
.
querylist
is
None
:
if
self
.
querylist
is
None
:
return
return
...
@@ -175,7 +178,7 @@ def gen_pair(querylist, partial_order="full"):
...
@@ -175,7 +178,7 @@ def gen_pair(querylist, partial_order="full"):
def
gen_list
(
querylist
):
def
gen_list
(
querylist
):
"""
"""
gen
pair for pair
-wise learning to rank algorithm
gen
item in list for list
-wise learning to rank algorithm
Paramters:
Paramters:
--------
--------
querylist : querylist, one query match many docment pairs in list, see QueryList
querylist : querylist, one query match many docment pairs in list, see QueryList
...
@@ -190,7 +193,9 @@ def gen_list(querylist):
...
@@ -190,7 +193,9 @@ def gen_list(querylist):
querylist
.
_correct_ranking_
()
querylist
.
_correct_ranking_
()
relevance_score_list
=
[
query
.
relevance_score
for
query
in
querylist
]
relevance_score_list
=
[
query
.
relevance_score
for
query
in
querylist
]
feature_vector_list
=
[
query
.
feature_vector
for
query
in
querylist
]
feature_vector_list
=
[
query
.
feature_vector
for
query
in
querylist
]
yield
np
.
array
(
relevance_score_list
).
T
,
np
.
array
(
feature_vector_list
)
# yield np.array(relevance_score_list).T, np.array(feature_vector_list)
for
i
in
range
(
len
(
querylist
)):
yield
relevance_score_list
[
i
],
np
.
array
(
feature_vector_list
[
i
])
def
load_from_text
(
filepath
,
shuffle
=
True
,
fill_missing
=-
1
):
def
load_from_text
(
filepath
,
shuffle
=
True
,
fill_missing
=-
1
):
...
@@ -236,7 +241,9 @@ def __reader__(filepath, format="pairwise", shuffle=True, fill_missing=-1):
...
@@ -236,7 +241,9 @@ def __reader__(filepath, format="pairwise", shuffle=True, fill_missing=-1):
for
pair
in
gen_pair
(
querylist
):
for
pair
in
gen_pair
(
querylist
):
yield
pair
yield
pair
elif
format
==
"listwise"
:
elif
format
==
"listwise"
:
yield
next
(
gen_list
(
querylist
))
# yield next(gen_list(querylist))
for
instance
in
gen_list
(
querylist
):
yield
instance
train
=
functools
.
partial
(
__reader__
,
filepath
=
"MQ2007/MQ2007/Fold1/train.txt"
)
train
=
functools
.
partial
(
__reader__
,
filepath
=
"MQ2007/MQ2007/Fold1/train.txt"
)
test
=
functools
.
partial
(
__reader__
,
filepath
=
"MQ2007/MQ2007/Fold1/test.txt"
)
test
=
functools
.
partial
(
__reader__
,
filepath
=
"MQ2007/MQ2007/Fold1/test.txt"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录