for k, v in pretrained_dict.items() if k in model_dict } # del pretrained_dict['classifier.6.bias'] # del pretrained_dict['classifier.6.weight'] model_dict.update(pretrained_dict) model.load_state_dict(model_dict) if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('--load', help='Resume from checkpoint file') args = parser.parse_args() for with_coral in [False, True]: model = models.DeepCORAL(31) # support different learning rate according to CORAL paper # i.e. 10 times learning rate for the last two fc layers. optimizer = torch.optim.SGD([ { 'params': model.sharedNet.parameters() }, { 'params': model.fc.parameters(), 'lr': 10 * LEARNING_RATE }, ], lr=LEARNING_RATE, momentum=MOMENTUM) if CUDA:
k: v for k, v in pretrained_dict.items() if k in model_dict } # del pretrained_dict['classifier.6.bias'] # del pretrained_dict['classifier.6.weight'] model_dict.update(pretrained_dict) model.load_state_dict(model_dict) if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('--load', help='Resume from checkpoint file') args = parser.parse_args() model = models.DeepCORAL(31) # num_classes=31 # support different learning rate according to CORAL paper # i.e. 10 times learning rate for the last two fc layers. optimizer = torch.optim.SGD([ { 'params': model.sharedNet.parameters() }, { 'params': model.fc.parameters(), 'lr': 10 * LEARNING_RATE }, ], lr=LEARNING_RATE, momentum=MOMENTUM)