Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add start_record interface #3128

Merged
merged 6 commits into from
Aug 1, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions go/pserver/client/c/test/test_train.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ def main():

# event_handler to print training and testing info
def event_handler(event):
if isinstance(event, paddle.event.BeginPass):
master_client.paddle_start_get_records(event.pass_id)

if isinstance(event, paddle.event.EndIteration):
# FIXME: for cloud data reader, pass number is managed by master
# should print the server side pass number
Expand Down
11 changes: 9 additions & 2 deletions python/paddle/v2/reader/creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ def reader():
return dec.buffered(reader, buf_size)


pass_num = 0


def recordio(paths, buf_size=100):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the name recordio as cloud_reader is more clear?

Copy link
Contributor Author

@Yancey1989 Yancey1989 Aug 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, done.

"""
Creates a data reader that outputs record one one by one
Expand All @@ -90,6 +93,7 @@ def recordio(paths, buf_size=100):
"""
import os
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need some demo code of how to use this reader.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

import paddle.v2.master.client as cloud
import cPickle as pickle
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this, not see anywhere it being used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, it's my mistake, we need pickle.loads() with the record fetched from master.
Done.


if "KUBERNETES_SERVICE_HOST" not in os.environ.keys():
return recordio_local(paths)
Expand All @@ -98,14 +102,17 @@ def recordio(paths, buf_size=100):
if host_name not in os.environ.keys():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the line host_name = "MASTER_SERVICE_HOST" we don't have a "master service" currently.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

raise Exception('not find ' + host_name + ' in environment variable.')

addr = os.environ(host)
addr = os.getenv(host_name)

def reader():
c = cloud(addr, buf_size)
c.set_dataset(paths)
c.paddle_start_get_records(pass_id)
global pass_num
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put global the first line under function define.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

pass_num += 1

while True:
r, err = client.next_record()
r, err = c.next_record()
if err < 0:
break
yield r
Expand Down