Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
book
提交
b170a71e
B
book
项目概览
PaddlePaddle
/
book
通知
16
Star
4
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
40
列表
看板
标记
里程碑
合并请求
37
Wiki
5
Wiki
分析
仓库
DevOps
项目成员
Pages
B
book
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
40
Issue
40
列表
看板
标记
里程碑
合并请求
37
合并请求
37
Pages
分析
分析
仓库分析
DevOps
Wiki
5
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
b170a71e
编写于
1月 11, 2019
作者:
W
wopeizl
提交者:
GitHub
1月 11, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #667 from wopeizl/fixbug
fix on python3 test=develop
上级
66e91259
6138fc77
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
14 addition
and
12 deletion
+14
-12
04.word2vec/train.py
04.word2vec/train.py
+5
-5
05.recommender_system/train.py
05.recommender_system/train.py
+9
-7
未找到文件。
04.word2vec/train.py
浏览文件 @
b170a71e
...
@@ -188,11 +188,11 @@ def infer(use_cuda, params_dirname=None):
...
@@ -188,11 +188,11 @@ def infer(use_cuda, params_dirname=None):
# meaning there is only one level of detail and there is only one sequence of
# meaning there is only one level of detail and there is only one sequence of
# one word on this level.
# one word on this level.
# Note that recursive_sequence_lengths should be a list of lists.
# Note that recursive_sequence_lengths should be a list of lists.
data1
=
[[
211L
]]
# 'among'
data1
=
[[
numpy
.
int64
(
211
)
]]
# 'among'
data2
=
[[
6L
]]
# 'a'
data2
=
[[
numpy
.
int64
(
6
)
]]
# 'a'
data3
=
[[
96L
]]
# 'group'
data3
=
[[
numpy
.
int64
(
96
)
]]
# 'group'
data4
=
[[
4L
]]
# 'of'
data4
=
[[
numpy
.
int64
(
4
)
]]
# 'of'
lod
=
[[
1L
]]
lod
=
[[
numpy
.
int64
(
1
)
]]
first_word
=
fluid
.
create_lod_tensor
(
data1
,
lod
,
place
)
first_word
=
fluid
.
create_lod_tensor
(
data1
,
lod
,
place
)
second_word
=
fluid
.
create_lod_tensor
(
data2
,
lod
,
place
)
second_word
=
fluid
.
create_lod_tensor
(
data2
,
lod
,
place
)
...
...
05.recommender_system/train.py
浏览文件 @
b170a71e
...
@@ -271,26 +271,28 @@ def infer(use_cuda, params_dirname):
...
@@ -271,26 +271,28 @@ def infer(use_cuda, params_dirname):
# Correspondingly, recursive_sequence_lengths = [[3, 2]] contains one
# Correspondingly, recursive_sequence_lengths = [[3, 2]] contains one
# level of detail info, indicating that `data` consists of two sequences
# level of detail info, indicating that `data` consists of two sequences
# of length 3 and 2, respectively.
# of length 3 and 2, respectively.
user_id
=
fluid
.
create_lod_tensor
([[
1L
]],
[[
1
]],
place
)
user_id
=
fluid
.
create_lod_tensor
([[
np
.
int64
(
1
)
]],
[[
1
]],
place
)
assert
feed_target_names
[
1
]
==
"gender_id"
assert
feed_target_names
[
1
]
==
"gender_id"
gender_id
=
fluid
.
create_lod_tensor
([[
1L
]],
[[
1
]],
place
)
gender_id
=
fluid
.
create_lod_tensor
([[
np
.
int64
(
1
)
]],
[[
1
]],
place
)
assert
feed_target_names
[
2
]
==
"age_id"
assert
feed_target_names
[
2
]
==
"age_id"
age_id
=
fluid
.
create_lod_tensor
([[
0L
]],
[[
1
]],
place
)
age_id
=
fluid
.
create_lod_tensor
([[
np
.
int64
(
0
)
]],
[[
1
]],
place
)
assert
feed_target_names
[
3
]
==
"job_id"
assert
feed_target_names
[
3
]
==
"job_id"
job_id
=
fluid
.
create_lod_tensor
([[
10L
]],
[[
1
]],
place
)
job_id
=
fluid
.
create_lod_tensor
([[
np
.
int64
(
10
)
]],
[[
1
]],
place
)
assert
feed_target_names
[
4
]
==
"movie_id"
assert
feed_target_names
[
4
]
==
"movie_id"
movie_id
=
fluid
.
create_lod_tensor
([[
783L
]],
[[
1
]],
place
)
movie_id
=
fluid
.
create_lod_tensor
([[
np
.
int64
(
783
)
]],
[[
1
]],
place
)
assert
feed_target_names
[
5
]
==
"category_id"
assert
feed_target_names
[
5
]
==
"category_id"
category_id
=
fluid
.
create_lod_tensor
([[
10L
,
8L
,
9L
]],
[[
3
]],
place
)
category_id
=
fluid
.
create_lod_tensor
(
[
np
.
array
([
10
,
8
,
9
],
dtype
=
'int64'
)],
[[
3
]],
place
)
assert
feed_target_names
[
6
]
==
"movie_title"
assert
feed_target_names
[
6
]
==
"movie_title"
movie_title
=
fluid
.
create_lod_tensor
(
movie_title
=
fluid
.
create_lod_tensor
(
[[
1069L
,
4140L
,
2923L
,
710L
,
988L
]],
[[
5
]],
place
)
[
np
.
array
([
1069
,
4140
,
2923
,
710
,
988
],
dtype
=
'int64'
)],
[[
5
]],
place
)
# Construct feed as a dictionary of {feed_target_name: feed_target_data}
# Construct feed as a dictionary of {feed_target_name: feed_target_data}
# and results will contain a list of data corresponding to fetch_targets.
# and results will contain a list of data corresponding to fetch_targets.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录