diff --git a/fit_a_line/README.md b/fit_a_line/README.md index 3a5a638d79ab29a6c9e54daff329dd207c8da058..f2e3243a3d1b91df5b8c9bfaa5da74fd142a63b3 100644 --- a/fit_a_line/README.md +++ b/fit_a_line/README.md @@ -151,10 +151,10 @@ trainer = paddle.trainer.SGD(cost=cost, ### 读取数据且打印训练的中间信息 在程序中,我们通过reader接口来获取训练或者测试的数据,通过eventhandler来打印训练的中间信息 -reader_dict中设置了训练数据和测试数据的下标,reader通过下标区分训练和测试数据。 +feeding中设置了训练数据和测试数据的下标,reader通过下标区分训练和测试数据。 ```python -reader_dict={'x': 0, +feeding={'x': 0, 'y': 1} # event_handler to print training and testing info @@ -168,7 +168,7 @@ def event_handler(event): result = trainer.test( reader=paddle.batch( uci_housing.test(), batch_size=2), - reader_dict=reader_dict) + feeding=feeding) print "Test %d, Cost %f" % (event.pass_id, result.cost) ``` ### 开始训练 @@ -180,7 +180,7 @@ trainer.train( paddle.reader.shuffle( uci_housing.train(), buf_size=500), batch_size=2), - reader_dict=reader_dict, + feeding=feeding, event_handler=event_handler, num_passes=30) ``` diff --git a/fit_a_line/train.py b/fit_a_line/train.py index 0986569c909e204a6425b935ee7e918ebb55cb89..df665c436872bbaaf5c08790cba69c8ac17e5db7 100644 --- a/fit_a_line/train.py +++ b/fit_a_line/train.py @@ -22,7 +22,7 @@ def main(): parameters=parameters, update_equation=optimizer) - reader_dict = {'x': 0, 'y': 1} + feeding = {'x': 0, 'y': 1} # event_handler to print training and testing info def event_handler(event): @@ -35,7 +35,7 @@ def main(): result = trainer.test( reader=paddle.batch( uci_housing.test(), batch_size=2), - reader_dict=reader_dict) + feeding=feeding) print "Test %d, Cost %f" % (event.pass_id, result.cost) # training @@ -44,7 +44,7 @@ def main(): paddle.reader.shuffle( uci_housing.train(), buf_size=500), batch_size=2), - reader_dict=reader_dict, + feeding=feeding, event_handler=event_handler, num_passes=30)