src/train.py
def init_dataset(opt):
    '''
    Initialize the datasets, samplers and dataloaders
    '''
    train_dataset = OmniglotDataset(mode='train',
                                    root=opt.dataset_root,
                                    transform=transforms.Compose([
                                        transforms.ToTensor(),
                                        transforms.Normalize(
                                            [0.5, 0.5, 0.5], [0.5, 0.5, 0.5]),
                                    ]))

    val_dataset = OmniglotDataset(mode='val',
                                  root=opt.dataset_root,
                                  transform=transforms.Compose([
                                      transforms.ToTensor(),
                                      transforms.Normalize(
                                          [0.5, 0.5, 0.5], [0.5, 0.5, 0.5]),
                                  ]))

    tr_sampler = PrototypicalBatchSampler(labels=train_dataset.y,
                                          classes_per_it=opt.classes_per_it_tr,
                                          num_support=opt.num_support_tr,
                                          num_query=opt.num_query_tr,
                                          iterations=opt.iterations)

    val_sampler = PrototypicalBatchSampler(labels=val_dataset.y,
                                           classes_per_it=opt.classes_per_it_val,
                                           num_support=opt.num_support_val,
                                           num_query=opt.num_query_val,
                                           iterations=opt.iterations)

    tr_dataloader = torch.utils.data.DataLoader(train_dataset,
                                                batch_sampler=tr_sampler)

    val_dataloader = torch.utils.data.DataLoader(val_dataset,
                                                 batch_sampler=val_sampler)
    return tr_dataloader, val_dataloader

    Initialize the datasets, samplers and dataloaders
    
Initialize the datasets, samplers and dataloaders
Initialize the datasets samplers and dataloaders
def init_dataset(opt):
    train_dataset = OmniglotDataset(mode='train',
                                    root=opt.dataset_root,
                                    transform=transforms.Compose([
                                        transforms.ToTensor(),
                                        transforms.Normalize(
                                            [0.5, 0.5, 0.5], [0.5, 0.5, 0.5]),
                                    ]))
    val_dataset = OmniglotDataset(mode='val',
                                  root=opt.dataset_root,
                                  transform=transforms.Compose([
                                      transforms.ToTensor(),
                                      transforms.Normalize(
                                          [0.5, 0.5, 0.5], [0.5, 0.5, 0.5]),
                                  ]))
    tr_sampler = PrototypicalBatchSampler(labels=train_dataset.y,
                                          classes_per_it=opt.classes_per_it_tr,
                                          num_support=opt.num_support_tr,
                                          num_query=opt.num_query_tr,
                                          iterations=opt.iterations)
    val_sampler = PrototypicalBatchSampler(labels=val_dataset.y,
                                           classes_per_it=opt.classes_per_it_val,
                                           num_support=opt.num_support_val,
                                           num_query=opt.num_query_val,
                                           iterations=opt.iterations)
    tr_dataloader = torch.utils.data.DataLoader(train_dataset,
                                                batch_sampler=tr_sampler)
    val_dataloader = torch.utils.data.DataLoader(val_dataset,
                                                 batch_sampler=val_sampler)
    return tr_dataloader, val_dataloader
def init_dataset ( opt ) : train_dataset = OmniglotDataset ( mode = 'train' , root = opt . dataset_root , transform = transforms . Compose ( [ transforms . ToTensor ( ) , transforms . Normalize ( [ 0.5 , 0.5 , 0.5 ] , [ 0.5 , 0.5 , 0.5 ] ) , ] ) ) val_dataset = OmniglotDataset ( mode = 'val' , root = opt . dataset_root , transform = transforms . Compose ( [ transforms . ToTensor ( ) , transforms . Normalize ( [ 0.5 , 0.5 , 0.5 ] , [ 0.5 , 0.5 , 0.5 ] ) , ] ) ) tr_sampler = PrototypicalBatchSampler ( labels = train_dataset . y , classes_per_it = opt . classes_per_it_tr , num_support = opt . num_support_tr , num_query = opt . num_query_tr , iterations = opt . iterations ) val_sampler = PrototypicalBatchSampler ( labels = val_dataset . y , classes_per_it = opt . classes_per_it_val , num_support = opt . num_support_val , num_query = opt . num_query_val , iterations = opt . iterations ) tr_dataloader = torch . utils . data . DataLoader ( train_dataset , batch_sampler = tr_sampler ) val_dataloader = torch . utils . data . DataLoader ( val_dataset , batch_sampler = val_sampler ) return tr_dataloader , val_dataloader
Initialize the datasets, samplers and dataloaders
Initialize the datasets samplers and dataloaders
'''
    Initialize the datasets, samplers and dataloaders
    '''
opt