'recon_poeA', 'recon_poeB', 'recon_crA', 'recon_crB', 'total_loss', 'test_total_loss', 'test_acc', 'val_total_loss', 'val_acc', 'test_f1', 'val_f1') VIZ = visdom.Visdom(port=args.viz_port) viz_init() preprocess_data = transforms.Compose([ transforms.CenterCrop((168, 178)), transforms.Resize((64, 64)), transforms.ToTensor(), ]) train_data = torch.utils.data.DataLoader(datasets( partition='train', data_dir='../../data/celeba2', image_transform=preprocess_data), batch_size=args.batch_size, shuffle=True) test_data = torch.utils.data.DataLoader(datasets( partition='test', data_dir='../../data/celeba2', image_transform=preprocess_data), batch_size=args.batch_size, shuffle=False) val_data = torch.utils.data.DataLoader(datasets( partition='val', data_dir='../../data/celeba2', image_transform=preprocess_data), batch_size=args.batch_size,
if args.viz_on: WIN_ID = dict( llA='win_llA', llB='win_llB', total_losses='win_total_losses', llB_test='win_llB_test', llA_test='win_llA_test' ) LINE_GATHER = probtorch.util.DataGather( 'epoch', 'recon_A', 'recon_B', 'total_loss', 'test_total_loss', 'recon_A_test', 'recon_B_test' ) VIZ = visdom.Visdom(port=args.viz_port) viz_init() train_data = torch.utils.data.DataLoader(datasets(path, ATTR_IDX, train=True, crop=1.2), batch_size=args.batch_size, shuffle=True, num_workers=len(GPU)) test_data = torch.utils.data.DataLoader(datasets(path, ATTR_IDX, train=False, crop=1.2), batch_size=args.batch_size, shuffle=True, num_workers=len(GPU)) BIAS_TRAIN = (train_data.dataset.__len__() - 1) / (args.batch_size - 1) BIAS_TEST = (test_data.dataset.__len__() - 1) / (args.batch_size - 1) def cuda_tensors(obj): for attr in dir(obj): value = getattr(obj, attr) if isinstance(value, torch.Tensor): setattr(obj, attr, value.cuda())
llB_test='win_llB_test', llA_test='win_llA_test', llB_val='win_llB_val', llA_val='win_llA_val', acc='win_acc') LINE_GATHER = probtorch.util.DataGather('epoch', 'recon_A', 'recon_B', 'total_loss', 'test_total_loss', 'recon_A_test', 'recon_B_test', 'val_total_loss', 'recon_A_val', 'recon_B_val', 'tr_acc', 'te_acc', 'val_acc') VIZ = visdom.Visdom(port=args.viz_port) viz_init() train_data = torch.utils.data.DataLoader(datasets(path, ATTR_IDX, train=True, crop=1.2), batch_size=args.batch_size, shuffle=True, num_workers=len(GPU)) test_data = torch.utils.data.DataLoader(datasets(path, ATTR_IDX, train=False, crop=1.2), batch_size=args.batch_size, shuffle=True, num_workers=len(GPU)) val_data = torch.utils.data.DataLoader(datasets(path, ATTR_IDX, train=True,
'test_acc') VIZ = visdom.Visdom(port=args.viz_port) viz_init() path = '../../data/awa/Animals_with_Attributes2/' test_classes = np.genfromtxt(path + 'testclasses.txt', delimiter='\n', dtype=str) class_meta = np.genfromtxt(path + 'classes.txt', delimiter='\n', dtype=str) test_labels = [] for test_class in test_classes: for i in range(len(class_meta)): if test_class in class_meta[i]: test_labels.append(i) train_data = torch.utils.data.DataLoader(datasets(train=True), batch_size=args.batch_size, shuffle=True) test_data = torch.utils.data.DataLoader(datasets(train=False), batch_size=args.batch_size, shuffle=True) BIAS_TRAIN = (train_data.dataset.__len__() - 1) / (args.batch_size - 1) BIAS_TEST = (test_data.dataset.__len__() - 1) / (args.batch_size - 1) def cuda_tensors(obj): for attr in dir(obj): value = getattr(obj, attr) if isinstance(value, torch.Tensor): setattr(obj, attr, value.cuda())
win=WIN_ID['total_losses'], update='append', opts=dict(xlabel='epoch', ylabel='loss', title='Total Loss', legend=['train_loss', 'test_loss'])) if args.viz_on: WIN_ID = dict(total_losses='win_total_losses') LINE_GATHER = probtorch.util.DataGather('epoch', 'total_loss', 'test_total_loss') VIZ = visdom.Visdom(port=args.viz_port) viz_init() train_data = torch.utils.data.DataLoader(datasets(path, train=True, crop=1.2), batch_size=args.batch_size, shuffle=True, num_workers=len(GPU)) test_data = torch.utils.data.DataLoader(datasets(path, train=False, crop=1.2), batch_size=args.batch_size, shuffle=True, num_workers=len(GPU)) def cuda_tensors(obj): for attr in dir(obj): value = getattr(obj, attr) if isinstance(value, torch.Tensor): setattr(obj, attr, value.cuda())
acc='win_acc', total_losses='win_total_losses', f1='win_f1' ) LINE_GATHER = probtorch.util.DataGather( 'epoch', 'total_loss', 'test_acc', 'test_f1' ) VIZ = visdom.Visdom(port=args.viz_port) viz_init() preprocess_data = transforms.Compose([ transforms.CenterCrop((168, 178)), transforms.Resize((64, 64)), transforms.ToTensor(), ]) train_data = torch.utils.data.DataLoader(datasets(partition='train', data_dir='../../data/celeba2', image_transform=preprocess_data), batch_size=args.batch_size, shuffle=True) test_data = torch.utils.data.DataLoader(datasets(partition='test', data_dir='../../data/celeba2', image_transform=preprocess_data), batch_size=args.batch_size, shuffle=False) def cuda_tensors(obj): for attr in dir(obj): value = getattr(obj, attr) if isinstance(value, torch.Tensor): setattr(obj, attr, value.cuda()) encA = EncoderA(args.wseed, n_attr=N_ATTR) if CUDA: