1
- from __future__ import print_function
2
1
import argparse
3
2
import os
4
3
import shutil
@@ -60,10 +59,10 @@ def main():
60
59
61
60
# create model
62
61
if args .pretrained :
63
- print ("=> using pre-trained model '{}'" .format (args .arch ), flush = True )
62
+ print ("=> using pre-trained model '{}'" .format (args .arch ))
64
63
model = models .__dict__ [args .arch ](pretrained = True )
65
64
else :
66
- print ("=> creating model '{}'" .format (args .arch ), flush = True )
65
+ print ("=> creating model '{}'" .format (args .arch ))
67
66
model = models .__dict__ [args .arch ]()
68
67
69
68
if args .arch .startswith ('alexnet' ) or args .arch .startswith ('vgg' ):
@@ -75,16 +74,15 @@ def main():
75
74
# optionally resume from a checkpoint
76
75
if args .resume :
77
76
if os .path .isfile (args .resume ):
78
- print ("=> loading checkpoint '{}'" .format (args .resume ), flush = True )
77
+ print ("=> loading checkpoint '{}'" .format (args .resume ))
79
78
checkpoint = torch .load (args .resume )
80
79
args .start_epoch = checkpoint ['epoch' ]
81
80
best_prec1 = checkpoint ['best_prec1' ]
82
81
model .load_state_dict (checkpoint ['state_dict' ])
83
82
print ("=> loaded checkpoint '{}' (epoch {})"
84
- .format (args .evaluate , checkpoint ['epoch' ]), flush = True )
83
+ .format (args .evaluate , checkpoint ['epoch' ]))
85
84
else :
86
- print ("=> no checkpoint found at '{}'" .format (args .resume ),
87
- flush = True )
85
+ print ("=> no checkpoint found at '{}'" .format (args .resume ))
88
86
89
87
cudnn .benchmark = True
90
88
@@ -191,8 +189,7 @@ def train(train_loader, model, criterion, optimizer, epoch):
191
189
'Prec@1 {top1.val:.3f} ({top1.avg:.3f})\t '
192
190
'Prec@5 {top5.val:.3f} ({top5.avg:.3f})' .format (
193
191
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 ))
196
193
197
194
198
195
def validate (val_loader , model , criterion ):
@@ -231,10 +228,10 @@ def validate(val_loader, model, criterion):
231
228
'Prec@1 {top1.val:.3f} ({top1.avg:.3f})\t '
232
229
'Prec@5 {top5.val:.3f} ({top5.avg:.3f})' .format (
233
230
i , len (val_loader ), batch_time = batch_time , loss = losses ,
234
- top1 = top1 , top5 = top5 ), flush = True )
231
+ top1 = top1 , top5 = top5 ))
235
232
236
233
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 ))
238
235
239
236
return top1 .avg
240
237
0 commit comments