Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
26e661bc
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
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看板
提交
26e661bc
编写于
7月 03, 2017
作者:
G
gongweibao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix by helin's comments
上级
af5ac2c4
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
25 addition
and
17 deletion
+25
-17
go/master/c/client.go
go/master/c/client.go
+2
-2
python/paddle/v2/master/client.py
python/paddle/v2/master/client.py
+2
-2
python/paddle/v2/reader/creator.py
python/paddle/v2/reader/creator.py
+21
-13
未找到文件。
go/master/c/client.go
浏览文件 @
26e661bc
...
...
@@ -106,7 +106,7 @@ func paddle_set_dataset(client C.paddle_master_client, path **C.char, size C.int
// return value:
// 0:ok
// -
2
:error
// -
1
:error
//export paddle_next_record
func
paddle_next_record
(
client
C
.
paddle_master_client
,
record
**
C
.
uchar
)
C
.
int
{
c
:=
get
(
client
)
...
...
@@ -115,7 +115,7 @@ func paddle_next_record(client C.paddle_master_client, record **C.uchar) C.int {
// Error
// TODO: return the type of error?
*
record
=
(
*
C
.
uchar
)(
nullPtr
)
return
-
2
return
-
1
}
if
len
(
r
)
==
0
{
...
...
python/paddle/v2/master/client.py
浏览文件 @
26e661bc
...
...
@@ -28,12 +28,12 @@ class client(object):
# return format: (record, errno)
# errno = 0: ok
# <
-1
: error
# <
0
: error
def
next_record
(
self
):
p
=
ctypes
.
c_char_p
()
ret
=
ctypes
.
pointer
(
p
)
size
=
lib
.
paddle_next_record
(
self
.
c
,
ret
)
if
size
<
-
1
:
if
size
<
0
:
# Error
return
None
,
size
...
...
python/paddle/v2/reader/creator.py
浏览文件 @
26e661bc
...
...
@@ -57,29 +57,31 @@ def text_file(path):
return
reader
def
recordio_local
(
paths
):
def
recordio_local
(
paths
,
buf_size
=
100
):
"""
Creates a data reader
that outputs record one one by one
from given local recordio fils path
.
Creates a data reader
from given RecordIO file paths separated by ",",
glob pattern is supported
.
:path: path of recordio files.
:returns: data reader of recordio files.
"""
import
recordio
as
rec
import
paddle.v2.reader.decorator
as
dec
def
reader
():
for
i
,
path
in
enumerate
(
paths
):
f
=
rec
.
reader
(
path
)
while
True
:
r
=
f
.
read
()
if
r
is
None
:
break
yield
r
f
.
close
()
a
=
','
.
join
(
paths
)
f
=
rec
.
reader
(
a
)
while
True
:
r
=
f
.
read
()
if
r
is
None
:
break
yield
r
f
.
close
()
return
dec
.
buffered
(
reader
,
buf_size
)
return
reader
def
recordio
(
paths
,
addr
=
""
,
buf_size
=
100
):
def
recordio
(
paths
,
buf_size
=
100
):
"""
Creates a data reader that outputs record one one by one
from given local or cloud recordio path.
...
...
@@ -92,6 +94,12 @@ def recordio(paths, addr="", buf_size=100):
if
"KUBERNETES_SERVICE_HOST"
not
in
os
.
environ
.
keys
():
return
recordio_local
(
paths
)
host_name
=
"MASTER_SERVICE_HOST"
if
host_name
not
in
os
.
environ
.
keys
():
raise
Exception
(
'not find '
+
host_name
+
' in environ.'
)
addr
=
os
.
environ
(
host
)
def
reader
():
c
=
cloud
(
addr
,
buf_size
)
c
.
set_dataset
(
paths
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录