Skip to content

Commit

Permalink
print with parentheses
Browse files Browse the repository at this point in the history
  • Loading branch information
ljk628 committed Sep 18, 2018
1 parent 1802e82 commit d1f4118
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
10 changes: 5 additions & 5 deletions mpi4pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class A(MPI.Intracomm):

def print_once(comm, *message):
if not comm or comm.Get_rank()==0:
print ''.join(str(i) for i in message)
print (''.join(str(i) for i in message))

def is_master(comm):
return not comm or comm.Get_rank()==0
Expand All @@ -31,7 +31,7 @@ def allreduce_max(comm, array, display_info=False):
total.fill(float_min)

if display_info:
print "(%d): sum=%f : size=%d"%(get_rank(comm), np.sum(array), array.nbytes)
print ("(%d): sum=%f : size=%d"%(get_rank(comm), np.sum(array), array.nbytes))
rows = str(comm.gather(array.shape[0]))
cols = str(comm.gather(array.shape[1]))
print_once(comm, "reduce: %s, %s"%(rows, cols))
Expand All @@ -48,7 +48,7 @@ def allreduce_min(comm, array, display_info=False):
total.fill(float_max)

if display_info:
print "(%d): sum=%f : size=%d"%(get_rank(comm), np.sum(array), array.nbytes)
print ("(%d): sum=%f : size=%d"%(get_rank(comm), np.sum(array), array.nbytes))
rows = str(comm.gather(array.shape[0]))
cols = str(comm.gather(array.shape[1]))
print_once(comm, "reduce: %s, %s"%(rows, cols))
Expand All @@ -66,7 +66,7 @@ def reduce_max(comm, array, display_info=False):
total.fill(float_min)

if display_info:
print "(%d): sum=%f : size=%d"%(get_rank(comm), np.sum(array), array.nbytes)
print ("(%d): sum=%f : size=%d"%(get_rank(comm), np.sum(array), array.nbytes))
rows = str(comm.gather(array.shape[0]))
cols = str(comm.gather(array.shape[1]))
print_once(comm, "reduce: %s, %s"%(rows, cols))
Expand All @@ -83,7 +83,7 @@ def reduce_min(comm, array, display_info=False):
total.fill(float_max)

if display_info:
print "(%d): sum=%f : size=%d"%(get_rank(comm), np.sum(array), array.nbytes)
print ("(%d): sum=%f : size=%d"%(get_rank(comm), np.sum(array), array.nbytes))
rows = str(comm.gather(array.shape[0]))
cols = str(comm.gather(array.shape[1]))
print_once(comm, "reduce: %s, %s"%(rows, cols))
Expand Down
6 changes: 5 additions & 1 deletion plot_1D.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@ def plot_1d_loss_err(surf_file, xmin=-1.0, xmax=1.0, loss_max=5, log=False, show
print('------------------------------------------------------------------')

f = h5py.File(surf_file,'r')
print f.keys()
x = f['xcoordinates'][:]
assert 'train_loss' in f.keys(), "'train_loss' does not exist"
train_loss = f['train_loss'][:]
train_acc = f['train_acc'][:]

print ("train_loss")
print(train_loss)
print (train_loss)
print ("train_acc")
print (train_acc)

xmin = xmin if xmin != -1.0 else min(x)
xmax = xmax if xmax != 1.0 else max(x)
Expand Down
2 changes: 1 addition & 1 deletion projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def setup_PCA_directions(args, model_files):
# load models and prepare the optimization path matrix
matrix = []
for model_file in model_files:
print model_file
print (model_file)
net2 = model_loader.load(args.dataset, args.model, model_file,
args.data_parallel)
if args.dir_type == 'weights':
Expand Down

0 comments on commit d1f4118

Please sign in to comment.