utils.writeLogs('\n[Phase 3] : Training model') print('| Training Epochs = ' + str(cf.num_epochs)) utils.writeLogs('| Training Epochs = ' + str(cf.num_epochs)) print('| Initial Learning Rate = ' + str(cf.lr)) utils.writeLogs('| Initial Learning Rate = ' + str(cf.lr)) print('| Optimizer = ' + str(cf.optim_type)) utils.writeLogs('| Optimizer = ' + str(cf.optim_type)) elapsed_time = 0 for epoch in range(cf.start_epoch, cf.start_epoch+cf.num_epochs): start_time = time.time() train(epoch) test(epoch) epoch_time = time.time() - start_time elapsed_time += epoch_time print('| Elapsed time : %d:%02d:%02d' %(cf.get_hms(elapsed_time))) utils.writeLogs(str('| Elapsed time : %d:%02d:%02d' %(cf.get_hms(elapsed_time)))) print('\n[Phase 4] : Testing model') utils.writeLogs('\n[Phase 4] : Testing model') print('* Test results : Acc@1 = %.2f%%' %(best_acc)) utils.writeLogs(str('* Test results : Acc@1 = %.2f%%' %(best_acc)))
'acc': acc, 'epoch': epoch, } if not os.path.isdir('checkpoint'): os.mkdir('checkpoint') save_point = './checkpoint/' + args.dataset + os.sep if not os.path.isdir(save_point): os.mkdir(save_point) torch.save(state, save_point + file_name + str(cf.num_samples) + '.t7') best_acc = acc print('\n[Phase 3] : Training model') print('| Training Epochs = ' + str(cf.num_epochs)) print('| Initial Learning Rate = ' + str(cf.lr)) print('| Optimizer = ' + str(cf.optim_type)) elapsed_time = 0 for epoch in range(cf.start_epoch, cf.start_epoch + cf.num_epochs): start_time = time.time() train(epoch) test(epoch) epoch_time = time.time() - start_time elapsed_time += epoch_time print('| Elapsed time : %d:%02d:%02d' % (cf.get_hms(elapsed_time))) print('\n[Phase 4] : Testing model') print('* Test results : Acc@1 = %.2f%%' % (best_acc))