Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
TonyTonyFun
Paddle
提交
ee1d08ab
P
Paddle
项目概览
TonyTonyFun
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ee1d08ab
编写于
8月 09, 2018
作者:
M
minqiyang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix CI issues
上级
46a26946
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
27 addition
and
21 deletion
+27
-21
python/paddle/dataset/movielens.py
python/paddle/dataset/movielens.py
+8
-3
python/paddle/dataset/wmt16.py
python/paddle/dataset/wmt16.py
+1
-1
python/paddle/fluid/compat.py
python/paddle/fluid/compat.py
+13
-15
python/paddle/fluid/op.py
python/paddle/fluid/op.py
+3
-0
python/paddle/fluid/tests/unittests/test_conv3d_transpose_op.py
.../paddle/fluid/tests/unittests/test_conv3d_transpose_op.py
+1
-1
python/paddle/fluid/tests/unittests/test_maxout_op.py
python/paddle/fluid/tests/unittests/test_maxout_op.py
+1
-1
未找到文件。
python/paddle/dataset/movielens.py
浏览文件 @
ee1d08ab
...
...
@@ -27,6 +27,8 @@ import paddle.dataset.common
import
re
import
random
import
functools
import
six
import
paddle.fluid.compat
as
cpt
__all__
=
[
'train'
,
'test'
,
'get_movie_title_dict'
,
'max_movie_id'
,
'max_user_id'
,
...
...
@@ -112,6 +114,7 @@ def __initialize_meta_info__():
categories_set
=
set
()
with
package
.
open
(
'ml-1m/movies.dat'
)
as
movie_file
:
for
i
,
line
in
enumerate
(
movie_file
):
line
=
cpt
.
to_literal_str
(
line
,
encoding
=
'latin'
)
movie_id
,
title
,
categories
=
line
.
strip
().
split
(
'::'
)
categories
=
categories
.
split
(
'|'
)
for
c
in
categories
:
...
...
@@ -136,6 +139,7 @@ def __initialize_meta_info__():
USER_INFO
=
dict
()
with
package
.
open
(
'ml-1m/users.dat'
)
as
user_file
:
for
line
in
user_file
:
line
=
cpt
.
to_literal_str
(
line
,
encoding
=
'latin'
)
uid
,
gender
,
age
,
job
,
_
=
line
.
strip
().
split
(
"::"
)
USER_INFO
[
int
(
uid
)]
=
UserInfo
(
index
=
uid
,
gender
=
gender
,
age
=
age
,
job_id
=
job
)
...
...
@@ -148,6 +152,7 @@ def __reader__(rand_seed=0, test_ratio=0.1, is_test=False):
with
zipfile
.
ZipFile
(
file
=
fn
)
as
package
:
with
package
.
open
(
'ml-1m/ratings.dat'
)
as
rating
:
for
line
in
rating
:
line
=
cpt
.
to_literal_str
(
line
,
encoding
=
'latin'
)
if
(
rand
.
random
()
<
test_ratio
)
==
is_test
:
uid
,
mov_id
,
rating
,
_
=
line
.
strip
().
split
(
"::"
)
uid
=
int
(
uid
)
...
...
@@ -187,7 +192,7 @@ def max_movie_id():
Get the maximum value of movie id.
"""
__initialize_meta_info__
()
return
reduce
(
__max_index_info__
,
list
(
MOVIE_INFO
.
values
())).
index
return
six
.
moves
.
reduce
(
__max_index_info__
,
list
(
MOVIE_INFO
.
values
())).
index
def
max_user_id
():
...
...
@@ -195,7 +200,7 @@ def max_user_id():
Get the maximum value of user id.
"""
__initialize_meta_info__
()
return
reduce
(
__max_index_info__
,
list
(
USER_INFO
.
values
())).
index
return
six
.
moves
.
reduce
(
__max_index_info__
,
list
(
USER_INFO
.
values
())).
index
def
__max_job_id_impl__
(
a
,
b
):
...
...
@@ -210,7 +215,7 @@ def max_job_id():
Get the maximum value of job id.
"""
__initialize_meta_info__
()
return
reduce
(
__max_job_id_impl__
,
list
(
USER_INFO
.
values
())).
job_id
return
six
.
moves
.
reduce
(
__max_job_id_impl__
,
list
(
USER_INFO
.
values
())).
job_id
def
movie_categories
():
...
...
python/paddle/dataset/wmt16.py
浏览文件 @
ee1d08ab
...
...
@@ -62,7 +62,7 @@ def __build_dict(tar_file, dict_size, save_path, lang):
word_dict
=
defaultdict
(
int
)
with
tarfile
.
open
(
tar_file
,
mode
=
"r"
)
as
f
:
for
line
in
f
.
extractfile
(
"wmt16/train"
):
line_split
=
line
.
strip
().
split
(
"
\t
"
)
line_split
=
line
.
strip
().
split
(
six
.
b
(
"
\t
"
)
)
if
len
(
line_split
)
!=
2
:
continue
sen
=
line_split
[
0
]
if
lang
==
"en"
else
line_split
[
1
]
for
w
in
sen
.
split
():
...
...
python/paddle/fluid/compat.py
浏览文件 @
ee1d08ab
...
...
@@ -13,39 +13,40 @@
# limitations under the License.
import
six
import
math
# str and bytes related functions
def
to_literal_str
(
obj
):
def
to_literal_str
(
obj
,
encoding
=
'utf-8'
):
if
isinstance
(
obj
,
list
):
return
[
_to_literal_str
(
item
)
for
item
in
obj
]
return
[
_to_literal_str
(
item
,
encoding
)
for
item
in
obj
]
elif
isinstance
(
obj
,
set
):
return
set
([
_to_literal_str
(
item
)
for
item
in
obj
])
return
set
([
_to_literal_str
(
item
,
encoding
)
for
item
in
obj
])
else
:
return
_to_literal_str
(
obj
)
return
_to_literal_str
(
obj
,
encoding
)
def
_to_literal_str
(
obj
):
def
_to_literal_str
(
obj
,
encoding
):
if
isinstance
(
obj
,
six
.
binary_type
):
return
obj
.
decode
(
'utf-8'
)
return
obj
.
decode
(
encoding
)
elif
isinstance
(
obj
,
six
.
text_type
):
return
obj
else
:
return
six
.
u
(
obj
)
def
to_bytes
(
obj
):
def
to_bytes
(
obj
,
encoding
=
'utf-8'
):
if
isinstance
(
obj
,
list
):
return
[
_to_bytes
(
item
)
for
item
in
obj
]
return
[
_to_bytes
(
item
,
encoding
)
for
item
in
obj
]
elif
isinstance
(
obj
,
set
):
return
set
([
_to_bytes
(
item
)
for
item
in
obj
])
return
set
([
_to_bytes
(
item
,
encoding
)
for
item
in
obj
])
else
:
return
_to_bytes
(
obj
)
return
_to_bytes
(
obj
,
encoding
)
def
_to_bytes
(
obj
):
def
_to_bytes
(
obj
,
encoding
):
if
isinstance
(
obj
,
six
.
text_type
):
return
obj
.
encode
(
'utf-8'
)
return
obj
.
encode
(
encoding
)
elif
isinstance
(
obj
,
six
.
binary_type
):
return
obj
else
:
...
...
@@ -53,9 +54,6 @@ def _to_bytes(obj):
# math related functions
import
math
def
round
(
x
,
d
=
0
):
"""
Compatible round which act the same behaviour in Python3.
...
...
python/paddle/fluid/op.py
浏览文件 @
ee1d08ab
...
...
@@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import
numpy
as
np
import
six
import
paddle.fluid.core
as
core
...
...
@@ -99,6 +100,8 @@ class OpDescCreationMethod(object):
new_attr
=
op_desc
.
attrs
.
add
()
new_attr
.
name
=
attr
.
name
new_attr
.
type
=
attr
.
type
if
isinstance
(
user_defined_attr
,
np
.
ndarray
):
user_defined_attr
=
user_defined_attr
.
tolist
()
if
attr
.
type
==
framework_pb2
.
INT
:
new_attr
.
i
=
user_defined_attr
elif
attr
.
type
==
framework_pb2
.
FLOAT
:
...
...
python/paddle/fluid/tests/unittests/test_conv3d_transpose_op.py
浏览文件 @
ee1d08ab
...
...
@@ -25,7 +25,7 @@ def conv3dtranspose_forward_naive(input_, filter_, attrs):
groups
=
attrs
[
'groups'
]
assert
in_c
==
f_c
out_c
=
f_out_c
*
groups
sub_in_c
=
in_c
/
groups
sub_in_c
=
in_c
/
/
groups
stride
,
pad
,
dilations
=
attrs
[
'strides'
],
attrs
[
'paddings'
],
attrs
[
'dilations'
]
...
...
python/paddle/fluid/tests/unittests/test_maxout_op.py
浏览文件 @
ee1d08ab
...
...
@@ -19,7 +19,7 @@ from op_test import OpTest
def
maxout_forward_naive
(
input
,
groups
):
s0
,
s1
,
s2
,
s3
=
input
.
shape
return
np
.
ndarray
([
s0
,
s1
/
groups
,
groups
,
s2
,
s3
],
\
return
np
.
ndarray
([
s0
,
s1
/
/
groups
,
groups
,
s2
,
s3
],
\
buffer
=
input
,
dtype
=
input
.
dtype
).
max
(
axis
=
(
2
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录