From 884b584bc02718a74bc4e765f0c897625de77ae5 Mon Sep 17 00:00:00 2001 From: Thong Date: Mon, 22 Jan 2018 11:49:21 -0800 Subject: [PATCH] python3 compatible --- MPIDriver.py | 2 +- mpi_learn/mpi/process.py | 2 +- mpi_learn/train/model.py | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/MPIDriver.py b/MPIDriver.py index b05d1fa..cf0417c 100755 --- a/MPIDriver.py +++ b/MPIDriver.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 ### This script creates an MPIManager object and launches distributed training. diff --git a/mpi_learn/mpi/process.py b/mpi_learn/mpi/process.py index e213e0f..09206a7 100644 --- a/mpi_learn/mpi/process.py +++ b/mpi_learn/mpi/process.py @@ -118,7 +118,7 @@ def print_metrics(self, metrics): """Display metrics computed during training or validation""" names = self.model.metrics_names if len(names) == 1: - print "%s: %.3f" % (names[0],metrics) + print ("%s: %.3f" % (names[0],metrics)) else: for name, metric in zip( names, metrics ): print ("{0}: {1:.3f}".format(name,metric)) diff --git a/mpi_learn/train/model.py b/mpi_learn/train/model.py index 34a49c6..cc74a13 100644 --- a/mpi_learn/train/model.py +++ b/mpi_learn/train/model.py @@ -31,7 +31,7 @@ def __init__(self, comm, filename=None,json_str=None, custom_objects={}, weights self.filename = filename self.json_str = json_str self.weights = weights - self.custom_objects = custom_objects + self.custom_objects = custom_objects super(ModelFromJson, self).__init__(comm) def build_model(self): @@ -51,7 +51,7 @@ def __init__(self, comm, filename=None, json_str=None, device_name='cpu', self.filename = filename self.json_str = json_str self.weights = weights - self.custom_objects = custom_objects + self.custom_objects = custom_objects self.device = self.get_device_name(device_name) super(ModelFromJsonTF, self).__init__(comm) @@ -66,11 +66,11 @@ def get_device_name(self, device): dev_num = int(device[3:]) dev_type = 'gpu' except ValueError: - print "GPU number could not be parsed from {}; using CPU".format(device) + print ("GPU number could not be parsed from {}; using CPU".format(device)) dev_num = 0 dev_type = 'cpu' else: - print "Please specify 'cpu' or 'gpuN' for device name" + print ("Please specify 'cpu' or 'gpuN' for device name") dev_num = 0 dev_type = 'cpu' return get_device_name(dev_type, dev_num, backend='tensorflow')