Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
e102e5dd
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看板
提交
e102e5dd
编写于
8月 08, 2018
作者:
M
minqiyang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix cifar10 decompress problem
上级
3ec6d60c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
23 addition
and
29 deletion
+23
-29
python/paddle/dataset/cifar.py
python/paddle/dataset/cifar.py
+9
-12
python/paddle/dataset/common.py
python/paddle/dataset/common.py
+2
-8
python/paddle/fluid/compat.py
python/paddle/fluid/compat.py
+2
-2
python/paddle/fluid/tests/book/high-level-api/image_classification/cifar10_small_test_set.py
...-level-api/image_classification/cifar10_small_test_set.py
+10
-7
未找到文件。
python/paddle/dataset/cifar.py
浏览文件 @
e102e5dd
...
@@ -32,7 +32,7 @@ import itertools
...
@@ -32,7 +32,7 @@ import itertools
import
numpy
import
numpy
import
paddle.dataset.common
import
paddle.dataset.common
import
tarfile
import
tarfile
from
six.moves
import
zip
import
six
from
six.moves
import
cPickle
as
pickle
from
six.moves
import
cPickle
as
pickle
__all__
=
[
'train100'
,
'test100'
,
'train10'
,
'test10'
,
'convert'
]
__all__
=
[
'train100'
,
'test100'
,
'train10'
,
'test10'
,
'convert'
]
...
@@ -46,25 +46,22 @@ CIFAR100_MD5 = 'eb9058c3a382ffc7106e4002c42a8d85'
...
@@ -46,25 +46,22 @@ CIFAR100_MD5 = 'eb9058c3a382ffc7106e4002c42a8d85'
def
reader_creator
(
filename
,
sub_name
,
cycle
=
False
):
def
reader_creator
(
filename
,
sub_name
,
cycle
=
False
):
def
read_batch
(
batch
):
def
read_batch
(
batch
):
data
=
batch
[
'data'
]
data
=
batch
[
six
.
b
(
'data'
)
]
labels
=
batch
.
get
(
'labels'
,
batch
.
get
(
'fine_labels'
,
None
))
labels
=
batch
.
get
(
six
.
b
(
'labels'
),
batch
.
get
(
six
.
b
(
'fine_labels'
)
,
None
))
assert
labels
is
not
None
assert
labels
is
not
None
for
sample
,
label
in
zip
(
data
,
labels
):
for
sample
,
label
in
six
.
moves
.
zip
(
data
,
labels
):
yield
(
sample
/
255.0
).
astype
(
numpy
.
float32
),
int
(
label
)
yield
(
sample
/
255.0
).
astype
(
numpy
.
float32
),
int
(
label
)
def
reader
():
def
reader
():
with
tarfile
.
open
(
filename
,
mode
=
'r'
)
as
f
:
with
tarfile
.
open
(
filename
,
mode
=
'r'
)
as
f
:
names
=
(
each_item
.
name
for
each_item
in
f
names
=
[
each_item
.
name
for
each_item
in
f
if
sub_name
in
each_item
.
name
]
if
sub_name
in
each_item
.
name
)
while
True
:
while
True
:
for
name
in
names
:
for
name
in
names
:
import
sys
if
six
.
PY2
:
print
(
name
)
batch
=
pickle
.
load
(
f
.
extractfile
(
name
))
sys
.
stdout
.
flush
()
else
:
print
(
f
.
extractfile
(
name
))
batch
=
pickle
.
load
(
f
.
extractfile
(
name
),
encoding
=
'bytes'
)
sys
.
stdout
.
flush
()
batch
=
pickle
.
load
(
f
.
extractfile
(
name
))
for
item
in
read_batch
(
batch
):
for
item
in
read_batch
(
batch
):
yield
item
yield
item
if
not
cycle
:
if
not
cycle
:
...
...
python/paddle/dataset/common.py
浏览文件 @
e102e5dd
...
@@ -87,20 +87,14 @@ def download(url, module_name, md5sum, save_name=None):
...
@@ -87,20 +87,14 @@ def download(url, module_name, md5sum, save_name=None):
if
total_length
is
None
:
if
total_length
is
None
:
with
open
(
filename
,
'wb'
)
as
f
:
with
open
(
filename
,
'wb'
)
as
f
:
import
sys
shutil
.
copyfileobj
(
r
.
raw
,
f
)
print
(
"write follow block"
)
sys
.
stdout
.
flush
()
shutil
.
copyfileobj
(
cpt
.
to_bytes
(
r
.
raw
),
f
)
else
:
else
:
with
open
(
filename
,
'wb'
)
as
f
:
with
open
(
filename
,
'wb'
)
as
f
:
import
sys
print
(
"write follow length"
)
sys
.
stdout
.
flush
()
dl
=
0
dl
=
0
total_length
=
int
(
total_length
)
total_length
=
int
(
total_length
)
for
data
in
r
.
iter_content
(
chunk_size
=
4096
):
for
data
in
r
.
iter_content
(
chunk_size
=
4096
):
dl
+=
len
(
data
)
dl
+=
len
(
data
)
f
.
write
(
cpt
.
to_bytes
(
data
)
)
f
.
write
(
data
)
done
=
int
(
50
*
dl
/
total_length
)
done
=
int
(
50
*
dl
/
total_length
)
sys
.
stdout
.
write
(
"
\r
[%s%s]"
%
(
'='
*
done
,
sys
.
stdout
.
write
(
"
\r
[%s%s]"
%
(
'='
*
done
,
' '
*
(
50
-
done
)))
' '
*
(
50
-
done
)))
...
...
python/paddle/fluid/compat.py
浏览文件 @
e102e5dd
...
@@ -27,7 +27,7 @@ def to_literal_str(obj):
...
@@ -27,7 +27,7 @@ def to_literal_str(obj):
def
_to_literal_str
(
obj
):
def
_to_literal_str
(
obj
):
if
isinstance
(
obj
,
six
.
binary_type
):
if
isinstance
(
obj
,
six
.
binary_type
):
return
obj
.
decode
(
'
latin-1
'
)
return
obj
.
decode
(
'
utf-8
'
)
elif
isinstance
(
obj
,
six
.
text_type
):
elif
isinstance
(
obj
,
six
.
text_type
):
return
obj
return
obj
else
:
else
:
...
@@ -45,7 +45,7 @@ def to_bytes(obj):
...
@@ -45,7 +45,7 @@ def to_bytes(obj):
def
_to_bytes
(
obj
):
def
_to_bytes
(
obj
):
if
isinstance
(
obj
,
six
.
text_type
):
if
isinstance
(
obj
,
six
.
text_type
):
return
obj
.
encode
(
'
latin-1
'
)
return
obj
.
encode
(
'
utf-8
'
)
elif
isinstance
(
obj
,
six
.
binary_type
):
elif
isinstance
(
obj
,
six
.
binary_type
):
return
obj
return
obj
else
:
else
:
...
...
python/paddle/fluid/tests/book/high-level-api/image_classification/cifar10_small_test_set.py
浏览文件 @
e102e5dd
...
@@ -32,8 +32,8 @@ import itertools
...
@@ -32,8 +32,8 @@ import itertools
import
numpy
import
numpy
import
paddle.dataset.common
import
paddle.dataset.common
import
tarfile
import
tarfile
import
six
from
six.moves
import
cPickle
as
pickle
from
six.moves
import
cPickle
as
pickle
from
six.moves
import
zip
__all__
=
[
'train10'
]
__all__
=
[
'train10'
]
...
@@ -44,20 +44,23 @@ CIFAR10_MD5 = 'c58f30108f718f92721af3b95e74349a'
...
@@ -44,20 +44,23 @@ CIFAR10_MD5 = 'c58f30108f718f92721af3b95e74349a'
def
reader_creator
(
filename
,
sub_name
,
batch_size
=
None
):
def
reader_creator
(
filename
,
sub_name
,
batch_size
=
None
):
def
read_batch
(
batch
):
def
read_batch
(
batch
):
data
=
batch
[
'data'
]
data
=
batch
[
six
.
b
(
'data'
)
]
labels
=
batch
.
get
(
'labels'
,
batch
.
get
(
'fine_labels'
,
None
))
labels
=
batch
.
get
(
six
.
b
(
'labels'
),
batch
.
get
(
six
.
b
(
'fine_labels'
)
,
None
))
assert
labels
is
not
None
assert
labels
is
not
None
for
sample
,
label
in
zip
(
data
,
labels
):
for
sample
,
label
in
six
.
moves
.
zip
(
data
,
labels
):
yield
(
sample
/
255.0
).
astype
(
numpy
.
float32
),
int
(
label
)
yield
(
sample
/
255.0
).
astype
(
numpy
.
float32
),
int
(
label
)
def
reader
():
def
reader
():
with
tarfile
.
open
(
filename
,
mode
=
'r'
)
as
f
:
with
tarfile
.
open
(
filename
,
mode
=
'r'
)
as
f
:
names
=
(
each_item
.
name
for
each_item
in
f
names
=
[
each_item
.
name
for
each_item
in
f
if
sub_name
in
each_item
.
name
)
if
sub_name
in
each_item
.
name
]
batch_count
=
0
batch_count
=
0
for
name
in
names
:
for
name
in
names
:
batch
=
pickle
.
load
(
f
.
extractfile
(
name
))
if
six
.
PY2
:
batch
=
pickle
.
load
(
f
.
extractfile
(
name
))
else
:
batch
=
pickle
.
load
(
f
.
extractfile
(
name
),
encoding
=
'bytes'
)
for
item
in
read_batch
(
batch
):
for
item
in
read_batch
(
batch
):
if
isinstance
(
batch_size
,
int
)
and
batch_count
>
batch_size
:
if
isinstance
(
batch_size
,
int
)
and
batch_count
>
batch_size
:
break
break
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录