diff --git a/README.md b/README.md index 6ad8f0c974e2a77b1466371442a8dc2c1afe6f07..4e688a11f93fd394f30cabebffcba4b93a27b9ec 100644 --- a/README.md +++ b/README.md @@ -27,40 +27,36 @@ pip install paddle-serving-server ``` python import sys import paddle -import paddle.fluid as fluid train_reader = paddle.batch(paddle.reader.shuffle( paddle.dataset.uci_housing.train(), buf_size=500), batch_size=16) -test_reader = paddle.batch(paddle.reader.shuffle( - paddle.dataset.uci_housing.test(), buf_size=500), batch_size=16) - -x = fluid.data(name='x', shape=[None, 13], dtype='float32') -y = fluid.data(name='y', shape=[None, 1], dtype='float32') +x = paddle.fluid.data(name='x', shape=[None, 13], dtype='float32') +y = paddle.fluid.data(name='y', shape=[None, 1], dtype='float32') -y_predict = fluid.layers.fc(input=x, size=1, act=None) -cost = fluid.layers.square_error_cost(input=y_predict, label=y) -avg_loss = fluid.layers.mean(cost) -sgd_optimizer = fluid.optimizer.SGD(learning_rate=0.01) +y_predict = paddle.fluid.layers.fc(input=x, size=1, act=None) +cost = paddle.fluid.layers.square_error_cost(input=y_predict, label=y) +avg_loss = paddle.fluid.layers.mean(cost) +sgd_optimizer = paddle.fluid.optimizer.SGD(learning_rate=0.01) sgd_optimizer.minimize(avg_loss) -place = fluid.CPUPlace() -feeder = fluid.DataFeeder(place=place, feed_list=[x, y]) -exe = fluid.Executor(place) -exe.run(fluid.default_startup_program()) +place = paddle.fluid.CPUPlace() +feeder = paddle.fluid.DataFeeder(place=place, feed_list=[x, y]) +exe = paddle.fluid.Executor(place) +exe.run(paddle.fluid.default_startup_program()) import paddle_serving_client.io as serving_io for pass_id in range(30): for data_train in train_reader(): avg_loss_value, = exe.run( - fluid.default_main_program(), + paddle.fluid.default_main_program(), feed=feeder.feed(data_train), fetch_list=[avg_loss]) serving_io.save_model( "serving_server_model", "serving_client_conf", - {"x": x}, {"y": y_predict}, fluid.default_main_program()) + {"x": x}, {"y": y_predict}, paddle.fluid.default_main_program()) ```