1- from  __future__ import  print_function 
21import  argparse 
32import  os 
43import  shutil 
@@ -60,10 +59,10 @@ def main():
6059
6160 # create model 
6261 if  args .pretrained :
63-  print ("=> using pre-trained model '{}'" .format (args .arch ),  flush = True )
62+  print ("=> using pre-trained model '{}'" .format (args .arch ))
6463 model  =  models .__dict__ [args .arch ](pretrained = True )
6564 else :
66-  print ("=> creating model '{}'" .format (args .arch ),  flush = True )
65+  print ("=> creating model '{}'" .format (args .arch ))
6766 model  =  models .__dict__ [args .arch ]()
6867
6968 if  args .arch .startswith ('alexnet' ) or  args .arch .startswith ('vgg' ):
@@ -75,16 +74,15 @@ def main():
7574 # optionally resume from a checkpoint 
7675 if  args .resume :
7776 if  os .path .isfile (args .resume ):
78-  print ("=> loading checkpoint '{}'" .format (args .resume ),  flush = True )
77+  print ("=> loading checkpoint '{}'" .format (args .resume ))
7978 checkpoint  =  torch .load (args .resume )
8079 args .start_epoch  =  checkpoint ['epoch' ]
8180 best_prec1  =  checkpoint ['best_prec1' ]
8281 model .load_state_dict (checkpoint ['state_dict' ])
8382 print ("=> loaded checkpoint '{}' (epoch {})" 
84-  .format (args .evaluate , checkpoint ['epoch' ]),  flush = True )
83+  .format (args .evaluate , checkpoint ['epoch' ]))
8584 else :
86-  print ("=> no checkpoint found at '{}'" .format (args .resume ),
87-  flush = True )
85+  print ("=> no checkpoint found at '{}'" .format (args .resume ))
8886
8987 cudnn .benchmark  =  True 
9088
@@ -191,8 +189,7 @@ def train(train_loader, model, criterion, optimizer, epoch):
191189 'Prec@1 {top1.val:.3f} ({top1.avg:.3f})\t ' 
192190 'Prec@5 {top5.val:.3f} ({top5.avg:.3f})' .format (
193191 epoch , i , len (train_loader ), batch_time = batch_time ,
194-  data_time = data_time , loss = losses , top1 = top1 , top5 = top5 ),
195-  flush = True )
192+  data_time = data_time , loss = losses , top1 = top1 , top5 = top5 ))
196193
197194
198195def  validate (val_loader , model , criterion ):
@@ -231,10 +228,10 @@ def validate(val_loader, model, criterion):
231228 'Prec@1 {top1.val:.3f} ({top1.avg:.3f})\t ' 
232229 'Prec@5 {top5.val:.3f} ({top5.avg:.3f})' .format (
233230 i , len (val_loader ), batch_time = batch_time , loss = losses ,
234-  top1 = top1 , top5 = top5 ),  flush = True )
231+  top1 = top1 , top5 = top5 ))
235232
236233 print (' * Prec@1 {top1.avg:.3f} Prec@5 {top5.avg:.3f}' 
237-  .format (top1 = top1 , top5 = top5 ),  flush = True )
234+  .format (top1 = top1 , top5 = top5 ))
238235
239236 return  top1 .avg 
240237
0 commit comments