GANs/Pix2Pix_Isola_et_al_2017/dataset.py
def mean_std(dataset):
    """Return the mean and std of the dataset."""
    loader = DataLoader(dataset, batch_size=128, num_workers=0, shuffle=False)

    mean_inputs = 0.
    std_inputs = 0.
    mean_targets = 0.
    std_targets = 0.

    for inputs, targets in tqdm(loader):

        inputs = inputs.to(DEVICE).view(inputs.size(0), inputs.size(1), -1)
        mean_inputs += inputs.mean(2).sum(0)
        std_inputs += inputs.std(2).sum(0)

        targets = targets.to(DEVICE).view(targets.size(0), inputs.size(1), -1)
        mean_targets += targets.mean(2).sum(0)
        std_targets += targets.std(2).sum(0)

    mean_inputs /= len(loader.dataset)
    std_inputs /= len(loader.dataset)
    mean_targets /= len(loader.dataset)
    std_targets /= len(loader.dataset)

    return (mean_inputs, std_inputs), (mean_targets, std_targets)
Return the mean and std of the dataset.
Return the mean and std of the dataset.
Return the mean and std of the dataset .
def mean_std(dataset):
    loader = DataLoader(dataset, batch_size=128, num_workers=0, shuffle=False)
    mean_inputs = 0.
    std_inputs = 0.
    mean_targets = 0.
    std_targets = 0.
    for inputs, targets in tqdm(loader):
        inputs = inputs.to(DEVICE).view(inputs.size(0), inputs.size(1), -1)
        mean_inputs += inputs.mean(2).sum(0)
        std_inputs += inputs.std(2).sum(0)
        targets = targets.to(DEVICE).view(targets.size(0), inputs.size(1), -1)
        mean_targets += targets.mean(2).sum(0)
        std_targets += targets.std(2).sum(0)
    mean_inputs /= len(loader.dataset)
    std_inputs /= len(loader.dataset)
    mean_targets /= len(loader.dataset)
    std_targets /= len(loader.dataset)
    return (mean_inputs, std_inputs), (mean_targets, std_targets)
def mean_std ( dataset ) : loader = DataLoader ( dataset , batch_size = 128 , num_workers = 0 , shuffle = False ) mean_inputs = 0. std_inputs = 0. mean_targets = 0. std_targets = 0. for inputs , targets in tqdm ( loader ) : inputs = inputs . to ( DEVICE ) . view ( inputs . size ( 0 ) , inputs . size ( 1 ) , - 1 ) mean_inputs += inputs . mean ( 2 ) . sum ( 0 ) std_inputs += inputs . std ( 2 ) . sum ( 0 ) targets = targets . to ( DEVICE ) . view ( targets . size ( 0 ) , inputs . size ( 1 ) , - 1 ) mean_targets += targets . mean ( 2 ) . sum ( 0 ) std_targets += targets . std ( 2 ) . sum ( 0 ) mean_inputs /= len ( loader . dataset ) std_inputs /= len ( loader . dataset ) mean_targets /= len ( loader . dataset ) std_targets /= len ( loader . dataset ) return ( mean_inputs , std_inputs ) , ( mean_targets , std_targets )
Return the mean and std of the dataset.
Return the mean and std of the dataset .
"""Return the mean and std of the dataset."""
dataset