Skip to content

Commit 91f0573

Browse files
committed
Fix the overfix of 2to3 for print function
1 parent 559d363 commit 91f0573

32 files changed

+156
-155
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ option(PY_VERSION "Compile PaddlePaddle with python3 support" ${PY_VER
7272
if(NOT PY_VERSION)
7373
set(PY_VERSION 2.7)
7474
endif()
75+
set(PYBIND11_PYTHON_VERSION ${PY_VERSION})
7576

7677
# CMAKE_BUILD_TYPE
7778
if(NOT CMAKE_BUILD_TYPE)

python/paddle/fluid/optimizer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def _create_param_lr(self, param_and_grad):
106106
param_lr = param.optimize_attr['learning_rate']
107107
if type(param_lr) == Variable:
108108
# param learning rate has been updated (LARS)
109-
print(("returns updated param lr ", param_lr))
109+
print("returns updated param lr ", param_lr)
110110
return param_lr
111111
else:
112112
if param_lr == 1.0:

python/paddle/fluid/tests/book/high-level-api/fit_a_line/test_fit_a_line.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def infer(use_cuda, inference_program, params_dirname=None):
9494
tensor_x = numpy.random.uniform(0, 10, [batch_size, 13]).astype("float32")
9595

9696
results = inferencer.infer({'x': tensor_x})
97-
print(("infer results: ", results[0]))
97+
print("infer results: ", results[0])
9898

9999

100100
def main(use_cuda):

python/paddle/fluid/tests/book/high-level-api/image_classification/test_image_classification_resnet.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def event_handler(event):
105105
avg_cost, accuracy = trainer.test(
106106
reader=test_reader, feed_order=['pixel', 'label'])
107107

108-
print(('Loss {0:2.2}, Acc {1:2.2}'.format(avg_cost, accuracy)))
108+
print('Loss {0:2.2}, Acc {1:2.2}'.format(avg_cost, accuracy))
109109

110110
if accuracy > 0.01: # Low threshold for speeding up CI
111111
if params_dirname is not None:
@@ -134,7 +134,7 @@ def infer(use_cuda, inference_program, params_dirname=None):
134134
tensor_img = numpy.random.rand(1, 3, 32, 32).astype("float32")
135135
results = inferencer.infer({'pixel': tensor_img})
136136

137-
print(("infer results: ", results))
137+
print("infer results: ", results)
138138

139139

140140
def main(use_cuda):

python/paddle/fluid/tests/book/high-level-api/image_classification/test_image_classification_vgg.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def event_handler(event):
8282
avg_cost, accuracy = trainer.test(
8383
reader=test_reader, feed_order=['pixel', 'label'])
8484

85-
print(('Loss {0:2.2}, Acc {1:2.2}'.format(avg_cost, accuracy)))
85+
print('Loss {0:2.2}, Acc {1:2.2}'.format(avg_cost, accuracy))
8686

8787
if accuracy > 0.01: # Low threshold for speeding up CI
8888
if params_dirname is not None:
@@ -111,7 +111,7 @@ def infer(use_cuda, inference_program, params_dirname=None):
111111
tensor_img = numpy.random.rand(1, 3, 32, 32).astype("float32")
112112
results = inferencer.infer({'pixel': tensor_img})
113113

114-
print(("infer results: ", results))
114+
print("infer results: ", results)
115115

116116

117117
def main(use_cuda):

python/paddle/fluid/tests/book/high-level-api/label_semantic_roles/test_label_semantic_roles_newapi.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def event_handler(event):
171171
# get avg cost
172172
avg_cost = np.array(avg_cost_set).mean()
173173

174-
print(("avg_cost: %s" % avg_cost))
174+
print("avg_cost: %s" % avg_cost)
175175

176176
if float(avg_cost) < 100.0: # Large value to increase CI speed
177177
trainer.save_params(params_dirname)
@@ -183,8 +183,8 @@ def event_handler(event):
183183
sys.exit("got NaN loss, training failed.")
184184

185185
elif isinstance(event, fluid.EndStepEvent):
186-
print(("Step {0}, Epoch {1} Metrics {2}".format(
187-
event.step, event.epoch, list(map(np.array, event.metrics)))))
186+
print("Step {0}, Epoch {1} Metrics {2}".format(
187+
event.step, event.epoch, list(map(np.array, event.metrics))))
188188
if event.step == 1: # Run 2 iterations to speed CI
189189
trainer.save_params(params_dirname)
190190
trainer.stop()
@@ -206,14 +206,14 @@ def infer(use_cuda, inference_program, params_dirname):
206206
inference_program, param_path=params_dirname, place=place)
207207

208208
# Setup input by creating LoDTensor to represent sequence of words.
209-
# Here each word is the basic element of the LoDTensor and the shape of
210-
# each word (base_shape) should be [1] since it is simply an index to
209+
# Here each word is the basic element of the LoDTensor and the shape of
210+
# each word (base_shape) should be [1] since it is simply an index to
211211
# look up for the corresponding word vector.
212212
# Suppose the recursive_sequence_lengths info is set to [[3, 4, 2]],
213-
# which has only one level of detail. Then the created LoDTensor will have only
214-
# one higher level structure (sequence of words, or sentence) than the basic
215-
# element (word). Hence the LoDTensor will hold data for three sentences of
216-
# length 3, 4 and 2, respectively.
213+
# which has only one level of detail. Then the created LoDTensor will have only
214+
# one higher level structure (sequence of words, or sentence) than the basic
215+
# element (word). Hence the LoDTensor will hold data for three sentences of
216+
# length 3, 4 and 2, respectively.
217217
# Note that recursive_sequence_lengths should be a list of lists.
218218
recursive_seq_lens = [[3, 4, 2]]
219219
base_shape = [1]
@@ -248,7 +248,7 @@ def infer(use_cuda, inference_program, params_dirname):
248248
},
249249
return_numpy=False)
250250

251-
print(("infer results: ", np.array(results[0]).shape))
251+
print("infer results: ", np.array(results[0]).shape)
252252

253253

254254
def main(use_cuda):

python/paddle/fluid/tests/book/high-level-api/machine_translation/test_machine_translation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def train(use_cuda, is_sparse, is_local=True):
197197

198198
def event_handler(event):
199199
if isinstance(event, fluid.EndStepEvent):
200-
print(('pass_id=' + str(event.epoch) + ' batch=' + str(event.step)))
200+
print('pass_id=' + str(event.epoch) + ' batch=' + str(event.step))
201201
if event.step == 10:
202202
trainer.stop()
203203

@@ -259,7 +259,7 @@ def decode_main(use_cuda, is_sparse):
259259
feed=feed_dict,
260260
fetch_list=[translation_ids, translation_scores],
261261
return_numpy=False)
262-
print((result_ids.recursive_sequence_lengths()))
262+
print(result_ids.recursive_sequence_lengths())
263263
break
264264

265265

python/paddle/fluid/tests/book/high-level-api/recognize_digits/test_recognize_digits_conv.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ def event_handler(event):
7878
avg_cost, acc = trainer.test(
7979
reader=test_reader, feed_order=['img', 'label'])
8080

81-
print(("avg_cost: %s" % avg_cost))
82-
print(("acc : %s" % acc))
81+
print("avg_cost: %s" % avg_cost)
82+
print("acc : %s" % acc)
8383

8484
if acc > 0.2: # Smaller value to increase CI speed
8585
trainer.save_params(params_dirname)
8686
else:
87-
print(('BatchID {0}, Test Loss {1:0.2}, Acc {2:0.2}'.format(
88-
event.epoch + 1, avg_cost, acc)))
87+
print('BatchID {0}, Test Loss {1:0.2}, Acc {2:0.2}'.format(
88+
event.epoch + 1, avg_cost, acc))
8989
if math.isnan(avg_cost):
9090
sys.exit("got NaN loss, training failed.")
9191
elif isinstance(event, fluid.EndStepEvent):
@@ -118,7 +118,7 @@ def infer(use_cuda, inference_program, params_dirname=None):
118118

119119
results = inferencer.infer({'img': tensor_img})
120120

121-
print(("infer results: ", results[0]))
121+
print("infer results: ", results[0])
122122

123123

124124
def main(use_cuda):

python/paddle/fluid/tests/book/high-level-api/recognize_digits/test_recognize_digits_mlp.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ def event_handler(event):
6161
avg_cost, acc = trainer.test(
6262
reader=test_reader, feed_order=['img', 'label'])
6363

64-
print(("avg_cost: %s" % avg_cost))
65-
print(("acc : %s" % acc))
64+
print("avg_cost: %s" % avg_cost)
65+
print("acc : %s" % acc)
6666

6767
if acc > 0.2: # Smaller value to increase CI speed
6868
trainer.save_params(params_dirname)
6969
else:
70-
print(('BatchID {0}, Test Loss {1:0.2}, Acc {2:0.2}'.format(
71-
event.epoch + 1, avg_cost, acc)))
70+
print('BatchID {0}, Test Loss {1:0.2}, Acc {2:0.2}'.format(
71+
event.epoch + 1, avg_cost, acc))
7272
if math.isnan(avg_cost):
7373
sys.exit("got NaN loss, training failed.")
7474

@@ -96,7 +96,7 @@ def infer(use_cuda, inference_program, params_dirname=None):
9696

9797
results = inferencer.infer({'img': tensor_img})
9898

99-
print(("infer results: ", results[0]))
99+
print("infer results: ", results[0])
100100

101101

102102
def main(use_cuda):

python/paddle/fluid/tests/book/high-level-api/recommender_system/test_recommender_system_newapi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def event_handler(event):
180180
# get avg cost
181181
avg_cost = np.array(avg_cost_set).mean()
182182

183-
print(("avg_cost: %s" % avg_cost))
183+
print("avg_cost: %s" % avg_cost)
184184

185185
if float(avg_cost) < 4: # Smaller value to increase CI speed
186186
trainer.save_params(params_dirname)
@@ -240,7 +240,7 @@ def infer(use_cuda, inference_program, params_dirname):
240240
},
241241
return_numpy=False)
242242

243-
print(("infer results: ", np.array(results[0])))
243+
print("infer results: ", np.array(results[0]))
244244

245245

246246
def main(use_cuda):

0 commit comments

Comments
 (0)