Esempio n. 1
0
    args = parser.parse_args()
    pprint(vars(args))

    set_gpu(args.gpu)
    save_path1 = '-'.join([args.dataset, args.model_type, 'ProtoNet'])
    save_path2 = '_'.join([
        str(args.shot),
        str(args.query),
        str(args.way),
        str(args.step_size),
        str(args.gamma),
        str(args.lr),
        str(args.temperature)
    ])
    args.save_path = save_path1 + '_' + save_path2
    ensure_path(args.save_path)

    if args.dataset == 'MiniImageNet':
        # Handle MiniImageNet
        from feat.dataloader.mini_imagenet import MiniImageNet as Dataset
    elif args.dataset == 'CUB':
        from feat.dataloader.cub import CUB as Dataset
    else:
        raise ValueError('Non-supported Dataset.')

    trainset = Dataset('train', args)
    train_sampler = CategoriesSampler(trainset.label, 100, args.way,
                                      args.shot + args.query)
    train_loader = DataLoader(dataset=trainset,
                              batch_sampler=train_sampler,
                              num_workers=8,
Esempio n. 2
0
    args = parser.parse_args()
    pprint(vars(args))

    set_gpu(args.gpu)
    save_path1 = '-'.join([args.dataset, args.model_type, 'ProtoNet'])
    save_path2 = '_'.join([
        str(args.shot),
        str(args.query),
        str(args.way),
        str(args.step_size),
        str(args.gamma),
        str(args.lr),
        str(args.temperature)
    ])
    args.save_path = osp.join(args.save_path, osp.join(save_path1, save_path2))
    ensure_path(save_path1, remove=False)
    ensure_path(args.save_path)

    if args.dataset == 'MiniImageNet':
        # Handle MiniImageNet
        from feat.dataloader.mini_imagenet import MiniImageNet as Dataset
    elif args.dataset == 'CUB':
        from feat.dataloader.cub import CUB as Dataset
    elif args.dataset == 'TieredImageNet':
        from feat.dataloader.tiered_imagenet import tieredImageNet as Dataset
    else:
        raise ValueError('Non-supported Dataset.')

    trainset = Dataset('train', args)
    train_sampler = CategoriesSampler(trainset.label, 5, args.way,
                                      args.shot + args.query)