def main(): args = argParser() cifarLoader = CifarLoader(args) net = args.model() print('The log is recorded in ') print(net.logFile.name) if os.path.isfile('model.pth'): net.load_state_dict(torch.load('model.pth')) criterion = net.criterion() optimizer = net.optimizer() for epoch in range(args.epochs): # loop over the dataset multiple times net.adjust_learning_rate(optimizer, epoch, args) train(net, cifarLoader, optimizer, criterion, epoch) if epoch % 10 == 0: # Comment out this part if you want a faster training test(net, cifarLoader, 'Train') test(net, cifarLoader, 'Test') torch.save(net.state_dict(), 'model.pth') print('The log is recorded in ') print(net.logFile.name)
def main(): args = argParser() cifarLoader = CifarLoader(args) if not os.path.exists(args.logdir): os.makedirs(args.logdir) device = torch.device("cuda" if args.cuda else "cpu") net = args.model(args.logdir, device).to(device) print('The log is recorded in ') print(net.logFile.name) criterion = net.criterion().to(device) optimizer = net.optimizer() for epoch in trange(args.epochs): # loop over the dataset multiple times net.adjust_learning_rate(optimizer, epoch, args) train(net, cifarLoader, optimizer, criterion, epoch, device) if epoch % 10 == 0: # Comment out this part if you want a faster training test(net, cifarLoader, device, 'Train') test(net, cifarLoader, device, 'Test') print('The log is recorded in ') print(net.logFile.name)
def main(): args = argParser() cifarLoader = CifarLoader(args) net = args.model() net.to(device) print('The log is recorded in ') print(net.logFile.name) criterion = net.criterion() optimizer = net.optimizer() for epoch in range(args.epochs): # loop over the dataset multiple times net.adjust_learning_rate(optimizer, epoch, args) train(net, cifarLoader, optimizer, criterion, epoch) if epoch % 1 == 0: # Comment out this part if you want a faster training test(net, cifarLoader, 'Train') test(net, cifarLoader, 'Test') print('The log is recorded in ') print(net.logFile.name)
def main(): # cuda = torch.device('cuda') # torch.set_default_tensor_type('torch.cuda.FloatTensor') args = argParser() cifarLoader = CifarLoader(args) net = args.model() # net.cuda() print('The log is recorded in ') print(net.logFile.name) criterion = net.criterion() optimizer = net.optimizer() for epoch in range(args.epochs): # loop over the dataset multiple times net.adjust_learning_rate(optimizer, epoch, args) train(net, cifarLoader, optimizer, criterion, epoch) if epoch % 1 == 0: # Comment out this part if you want a faster training test(net, cifarLoader, 'Train') test(net, cifarLoader, 'Test') print('The log is recorded in ') print(net.logFile.name)
def main(): args = argParser() use_cuda = args.cuda and torch.cuda.is_available() device = torch.device('cuda' if use_cuda else 'cpu') cifarLoader = CifarLoader(args) net = args.model().to(device) print('The log is recorded in ') print(net.logFile.name) criterion = net.criterion(args.loss) optimizer = net.optimizer() for epoch in range(args.epochs): # loop over the dataset multiple times net.adjust_learning_rate(optimizer, epoch, args) train(net, cifarLoader, device, optimizer, criterion, epoch) if epoch % 1 == 0: # Comment out this part if you want a faster training test(net, cifarLoader, device, 'Train') test(net, cifarLoader, device, 'Test') print('The log is recorded in ') print(net.logFile.name)