Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
fc3d0314
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看板
提交
fc3d0314
编写于
6月 29, 2017
作者:
G
gongweibao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
first add
上级
1a0fdb9e
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
49 addition
and
13 deletion
+49
-13
go/master/c/client.go
go/master/c/client.go
+5
-0
go/master/client.go
go/master/client.go
+2
-1
python/paddle/v2/master/client.py
python/paddle/v2/master/client.py
+3
-0
python/paddle/v2/reader/creator.py
python/paddle/v2/reader/creator.py
+38
-11
python/paddle/v2/reader/tests/creator_test.py
python/paddle/v2/reader/tests/creator_test.py
+1
-1
未找到文件。
go/master/c/client.go
浏览文件 @
fc3d0314
...
...
@@ -88,7 +88,12 @@ func paddle_set_dataset(client C.paddle_master_client, path **C.char, size C.int
func
paddle_next_record
(
client
C
.
paddle_master_client
,
record
**
C
.
uchar
)
C
.
int
{
c
:=
get
(
client
)
r
:=
c
.
NextRecord
()
if
r
==
nil
{
// EOF
return
-
1
}
if
len
(
r
)
==
0
{
// Empty record
*
record
=
(
*
C
.
uchar
)(
nullPtr
)
return
0
}
...
...
go/master/client.go
浏览文件 @
fc3d0314
...
...
@@ -60,6 +60,7 @@ func (c *Client) getRecords() {
}
err
=
f
.
Close
()
c
.
ch
<-
nil
if
err
!=
nil
{
log
.
Errorln
(
err
)
}
...
...
@@ -112,7 +113,7 @@ func (c *Client) monitorMaster(addr Addresser) {
//
// SetDataset can be call multiple times from different nodes. But
// only the first call will be honored.
func
(
c
*
Client
)
SetDataset
(
globPaths
[]
string
)
error
{
func
(
c
*
Client
)
SetDataset
(
globPaths
...
string
)
error
{
return
c
.
conn
.
Call
(
"Service.SetDataset"
,
globPaths
,
nil
)
}
...
...
python/paddle/v2/master/client.py
浏览文件 @
fc3d0314
...
...
@@ -30,6 +30,9 @@ class client(object):
p
=
ctypes
.
c_char_p
()
ret
=
ctypes
.
pointer
(
p
)
size
=
lib
.
paddle_next_record
(
self
.
c
,
ret
)
if
size
<
0
:
# EOF
return
None
if
size
==
0
:
# Empty record
return
""
...
...
python/paddle/v2/reader/creator.py
浏览文件 @
fc3d0314
...
...
@@ -57,22 +57,49 @@ def text_file(path):
return
reader
def
recordio
(
path
):
def
recordio
_local
(
paths
):
"""
Creates a data reader that outputs record one one by one from given recordio file
:path: path of recordio file
:returns: data reader of recordio file
Creates a data reader that outputs record one one by one
from given local recordio fils path.
:path: path of recordio files.
:returns: data reader of recordio files.
"""
import
recordio
as
rec
def
reader
():
f
=
rec
.
reader
(
path
)
while
True
:
r
=
f
.
read
()
if
r
is
None
:
break
yield
r
f
.
close
()
for
i
,
path
in
enumerate
(
paths
):
f
=
rec
.
reader
(
path
)
while
True
:
r
=
f
.
read
()
if
r
is
None
:
break
yield
r
f
.
close
()
return
reader
def
recordio
(
paths
,
addr
=
""
,
buf_size
=
100
):
"""
Creates a data reader that outputs record one one by one
from given local or cloud recordio path.
:path: path of recordio files.
:returns: data reader of recordio files.
"""
import
os
import
paddle.v2.master.client
as
cloud
if
len
(
os
.
environ
[
"KUBERNETES_SERVICE_HOST"
])
==
0
:
return
recordio_local
(
path
)
c
=
cloud
(
addr
,
buf_size
)
c
.
set_dataset
(
paths
)
while
True
:
r
=
client
.
next_record
()
if
r
is
None
:
break
yield
r
c
.
close
()
python/paddle/v2/reader/tests/creator_test.py
浏览文件 @
fc3d0314
...
...
@@ -38,7 +38,7 @@ class TestRecordIO(unittest.TestCase):
def
test_recordio
(
self
):
path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"test_recordio_creator.dat"
)
reader
=
paddle
.
v2
.
reader
.
creator
.
recordio
(
path
)
reader
=
paddle
.
v2
.
reader
.
creator
.
recordio
(
[
path
]
)
for
idx
,
r
in
enumerate
(
reader
()):
self
.
assertSequenceEqual
(
r
,
str
(
idx
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录