save_dir = os.path.join(save_dir_root, 'run_' + str(run_id)) if not os.path.exists(os.path.join(save_dir, 'models')): os.makedirs(os.path.join(save_dir, 'models')) # Network definition modelName = 'dextr_pascal' net = resnet.resnet101(1, pretrained=True, nInputChannels=nInputChannels, classifier=classifier) if resume_epoch == 0: print("Initializing from pretrained Deeplab-v2 model") else: print("Initializing weights from: {}".format( os.path.join(save_dir, 'models', modelName + '_epoch-' + str(resume_epoch - 1) + '.pth'))) net.load_state_dict( torch.load(os.path.join(save_dir, 'models', modelName + '_epoch-' + str(resume_epoch - 1) + '.pth'), map_location=lambda storage, loc: storage)) train_params = [{'params': resnet.get_1x_lr_params(net), 'lr': p['lr']}, {'params': resnet.get_10x_lr_params(net), 'lr': p['lr'] * 10}] net.to(device) # Training the network if resume_epoch != nEpochs: # Logging into Tensorboard log_dir = os.path.join(save_dir, 'models', datetime.now().strftime('%b%d_%H-%M-%S') + '_' + socket.gethostname()) # writer = SummaryWriter(log_dir=log_dir) # Use the following optimizer optimizer = optim.SGD(train_params, lr=p['lr'], momentum=p['momentum'], weight_decay=p['wd']) p['optimizer'] = str(optimizer) # Preparation of the data loaders
pretrained=True, nInputChannels=nInputChannels, classifier=classifier) if resume_epoch == 0: print("Initializing from pretrained Deeplab-v2 model") else: print("Initializing weights from: {}".format( os.path.join(save_dir, 'models', modelName + '_epoch-' + str(resume_epoch - 1) + '.pth'))) net.load_state_dict( torch.load(os.path.join( save_dir, 'models', modelName + '_epoch-' + str(resume_epoch - 1) + '.pth'), map_location=lambda storage, loc: storage)) train_params = [{ 'params': resnet.get_1x_lr_params(net), 'lr': p['lr'] }, { 'params': resnet.get_10x_lr_params(net), 'lr': p['lr'] * 10 }] # net.to(device) net = torch.nn.DataParallel(net.cuda()) # net.to(device) # Training the network if resume_epoch != nEpochs: # Logging into Tensorboard log_dir = os.path.join( save_dir, 'models',