diff --git a/python/paddle/fluid/distributed/node.py b/python/paddle/fluid/distributed/node.py index a15f94f4d17fca8f53340a31b9dab1951b72ac1c..5a1e9362c2fbcbbe85fc4eb360ec98e5951d9975 100644 --- a/python/paddle/fluid/distributed/node.py +++ b/python/paddle/fluid/distributed/node.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and import ps_pb2 as pslib +# NOTE: reduce removed in fuctools in python3 +from functools import reduce class Server(object): diff --git a/python/paddle/fluid/incubate/fleet/base/fleet_base.py b/python/paddle/fluid/incubate/fleet/base/fleet_base.py index 77a202317912f2ca1f72eb394b322b39062c8fbd..105180030ace8281dffa9860e82f0e515fd28a3b 100644 --- a/python/paddle/fluid/incubate/fleet/base/fleet_base.py +++ b/python/paddle/fluid/incubate/fleet/base/fleet_base.py @@ -181,7 +181,7 @@ class Fleet(object): trainers = self.worker_num() remainder = len(files) % trainers - blocksize = len(files) / trainers + blocksize = len(files) // trainers blocks = [blocksize] * trainers for i in range(remainder): diff --git a/python/paddle/fluid/incubate/fleet/utils/fleet_util.py b/python/paddle/fluid/incubate/fleet/utils/fleet_util.py index 979334ed2eaa4c0ceccec288be4987b54c72fe7e..d02be8af4b144f3797aadaeb2a763b24090e6178 100644 --- a/python/paddle/fluid/incubate/fleet/utils/fleet_util.py +++ b/python/paddle/fluid/incubate/fleet/utils/fleet_util.py @@ -244,7 +244,7 @@ class FleetUtil(object): new_pos = 0.0 new_neg = 0.0 total_ins_num = 0 - for i in xrange(num_bucket): + for i in range(num_bucket): index = num_bucket - 1 - i new_pos = pos + global_pos[0][index] total_ins_num += global_pos[0][index] @@ -1240,8 +1240,8 @@ class FleetUtil(object): hours = os.popen("echo -n " + hours).read().split(" ") split_interval = int(split_interval) split_per_pass = int(split_per_pass) - splits_per_day = 24 * 60 / split_interval - pass_per_day = splits_per_day / split_per_pass + splits_per_day = 24 * 60 // split_interval + pass_per_day = splits_per_day // split_per_pass left_train_hour = int(hours[0]) right_train_hour = int(hours[-1]) @@ -1425,7 +1425,7 @@ class FleetUtil(object): relative_ctr_error = 0.0 k_max_span = 0.01 k_relative_error_bound = 0.05 - for i in xrange(num_bucket): + for i in range(num_bucket): click = global_pos[0][i] show = global_pos[0][i] + global_neg[0][i] ctr = float(i) / num_bucket diff --git a/python/paddle/fluid/incubate/fleet/utils/http_server.py b/python/paddle/fluid/incubate/fleet/utils/http_server.py index 50933ce5d1bd35ac4596740f33c0a58c46a4f478..b4ee29a065a7c0a801ec2a408578c592f16c3d52 100644 --- a/python/paddle/fluid/incubate/fleet/utils/http_server.py +++ b/python/paddle/fluid/incubate/fleet/utils/http_server.py @@ -14,8 +14,9 @@ """Http Server.""" import logging -import BaseHTTPServer -import SimpleHTTPServer +# NOTE: HTTPServer has a different name in python2 and python3 +from http.server import HTTPServer +import http.server as SimpleHTTPServer import time import threading import socket @@ -123,7 +124,7 @@ class KVHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): self.end_headers() -class KVHTTPServer(BaseHTTPServer.HTTPServer, object): +class KVHTTPServer(HTTPServer, object): """ it is a http server storing kv pairs. """