Exemplo n.º 1
0
	def __init__(self, checkpoint_path, cp_name, loader, cuda):

		self.cp_task = os.path.join(checkpoint_path, 'task'+cp_name+'.pt') if cp_name else os.path.join(checkpoint_path, 'task_checkpoint_{}ep.pt')
		self.cp_domain = os.path.join(checkpoint_path, 'Domain_{}'+cp_name+'.pt') if cp_name else os.path.join(checkpoint_path, 'Domain_{}.pt')
		self.dataloader = loader
		self.cuda = cuda
		self.feature_extractor = models.AlexNet(num_classes = 7, baseline = False)
		self.task_classifier = models.task_classifier()
Exemplo n.º 2
0
                                               hdf_path3=test_source_3,
                                               transform=img_transform_test)
    test_source_loader = torch.utils.data.DataLoader(
        dataset=test_source_dataset,
        batch_size=args.batch_size,
        shuffle=True,
        num_workers=args.workers)

    target_dataset = Loader_validation(hdf_path=target_path,
                                       transform=img_transform_test)
    target_loader = torch.utils.data.DataLoader(dataset=target_dataset,
                                                batch_size=args.batch_size,
                                                shuffle=True,
                                                num_workers=args.workers)

    task_classifier = models.task_classifier()
    domain_discriminator_list = []
    for i in range(3):
        if args.rp_size == 4096:
            disc = models.domain_discriminator_ablation_RP(
                optim.SGD, args.lr_domain, args.momentum_domain,
                args.l2).train()
        else:
            disc = models.domain_discriminator(args.rp_size, optim.SGD,
                                               args.lr_domain,
                                               args.momentum_domain,
                                               args.l2).train()
        domain_discriminator_list.append(disc)

    #feature_extractor = models.AlexNet(num_classes = 7, baseline = False)
    feature_extractor = models.get_pretrained_model(args.train_model)