From 5829bd375931ffd40d91ef7038aaadb010d9023f Mon Sep 17 00:00:00 2001 From: JiabinYang Date: Sat, 14 Jul 2018 03:18:09 +0000 Subject: [PATCH] insert the header file and change print usage to match python3 style print() --- 02.recognize_digits/README.cn.md | 7 ++++--- 02.recognize_digits/README.md | 7 ++++--- 02.recognize_digits/index.cn.html | 7 ++++--- 02.recognize_digits/index.html | 7 ++++--- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/02.recognize_digits/README.cn.md b/02.recognize_digits/README.cn.md index 01a5c6e..ff6324b 100644 --- a/02.recognize_digits/README.cn.md +++ b/02.recognize_digits/README.cn.md @@ -155,6 +155,7 @@ PaddlePaddle在API中提供了自动加载[MNIST](http://yann.lecun.com/exdb/mni ```python import paddle import paddle.fluid as fluid +from __future__ import print_function ``` ### Program Functions 配置 @@ -294,8 +295,8 @@ def event_handler(event): if event.step % 100 == 0: # event.metrics maps with train program return arguments. # event.metrics[0] will yeild avg_cost and event.metrics[1] will yeild acc in this example. - print "Pass %d, Batch %d, Cost %f" % ( - event.step, event.epoch, event.metrics[0]) + print("Pass %d, Batch %d, Cost %f" % ( + event.step, event.epoch, event.metrics[0])) if isinstance(event, fluid.EndEpochEvent): avg_cost, acc = trainer.test( @@ -419,7 +420,7 @@ img = load_image(cur_dir + '/image/infer_3.png') ```python results = inferencer.infer({'img': img}) lab = np.argsort(results) # probs and lab are the results of one batch data -print "Inference result of image/infer_3.png is: %d" % lab[0][0][-1] +print ("Inference result of image/infer_3.png is: %d" % lab[0][0][-1]) ``` ## 总结 diff --git a/02.recognize_digits/README.md b/02.recognize_digits/README.md index b547e41..97e05cf 100644 --- a/02.recognize_digits/README.md +++ b/02.recognize_digits/README.md @@ -161,6 +161,7 @@ A PaddlePaddle program starts from importing the API package: ```python import paddle import paddle.fluid as fluid +from __future__ import print_function ``` ### Program Functions Configuration @@ -300,8 +301,8 @@ def event_handler(event): if event.step % 100 == 0: # event.metrics maps with train program return arguments. # event.metrics[0] will yeild avg_cost and event.metrics[1] will yeild acc in this example. - print "Pass %d, Batch %d, Cost %f" % ( - event.step, event.epoch, event.metrics[0]) + print("Pass %d, Batch %d, Cost %f" % ( + event.step, event.epoch, event.metrics[0])) if isinstance(event, fluid.EndEpochEvent): avg_cost, acc = trainer.test( @@ -432,7 +433,7 @@ Now we are ready to do inference. ```python results = inferencer.infer({'img': img}) lab = np.argsort(results) # probs and lab are the results of one batch data -print "Inference result of image/infer_3.png is: %d" % lab[0][0][-1] +print("Inference result of image/infer_3.png is: %d" % lab[0][0][-1]) ``` diff --git a/02.recognize_digits/index.cn.html b/02.recognize_digits/index.cn.html index da3ea3c..b2c6e6d 100644 --- a/02.recognize_digits/index.cn.html +++ b/02.recognize_digits/index.cn.html @@ -197,6 +197,7 @@ PaddlePaddle在API中提供了自动加载[MNIST](http://yann.lecun.com/exdb/mni ```python import paddle import paddle.fluid as fluid +from __future__ import print_function ``` ### Program Functions 配置 @@ -336,8 +337,8 @@ def event_handler(event): if event.step % 100 == 0: # event.metrics maps with train program return arguments. # event.metrics[0] will yeild avg_cost and event.metrics[1] will yeild acc in this example. - print "Pass %d, Batch %d, Cost %f" % ( - event.step, event.epoch, event.metrics[0]) + print("Pass %d, Batch %d, Cost %f" % ( + event.step, event.epoch, event.metrics[0])) if isinstance(event, fluid.EndEpochEvent): avg_cost, acc = trainer.test( @@ -461,7 +462,7 @@ img = load_image(cur_dir + '/image/infer_3.png') ```python results = inferencer.infer({'img': img}) lab = np.argsort(results) # probs and lab are the results of one batch data -print "Inference result of image/infer_3.png is: %d" % lab[0][0][-1] +print ("Inference result of image/infer_3.png is: %d" % lab[0][0][-1]) ``` ## 总结 diff --git a/02.recognize_digits/index.html b/02.recognize_digits/index.html index 9f0d51f..e508366 100644 --- a/02.recognize_digits/index.html +++ b/02.recognize_digits/index.html @@ -203,6 +203,7 @@ A PaddlePaddle program starts from importing the API package: ```python import paddle import paddle.fluid as fluid +from __future__ import print_function ``` ### Program Functions Configuration @@ -342,8 +343,8 @@ def event_handler(event): if event.step % 100 == 0: # event.metrics maps with train program return arguments. # event.metrics[0] will yeild avg_cost and event.metrics[1] will yeild acc in this example. - print "Pass %d, Batch %d, Cost %f" % ( - event.step, event.epoch, event.metrics[0]) + print("Pass %d, Batch %d, Cost %f" % ( + event.step, event.epoch, event.metrics[0])) if isinstance(event, fluid.EndEpochEvent): avg_cost, acc = trainer.test( @@ -474,7 +475,7 @@ Now we are ready to do inference. ```python results = inferencer.infer({'img': img}) lab = np.argsort(results) # probs and lab are the results of one batch data -print "Inference result of image/infer_3.png is: %d" % lab[0][0][-1] +print("Inference result of image/infer_3.png is: %d" % lab[0][0][-1]) ``` -- GitLab