Segmentation/UNet_Ronneberger_et_al_2015/dataset.py
def mean_std(dataset):
    """Return the mean and std of the dataset."""
    
    loader = DataLoader(dataset, batch_size=32, num_workers=0, shuffle=False)
    
    mean = 0.
    std = 0.
    for images, _ in loader:
        images = images.to(device)
        batch_samples = images.size(0)
        images = images.view(batch_samples, images.size(1), -1)
        mean += images.mean(2).sum(0)
        std += images.std(2).sum(0)
    
    mean /= len(loader.dataset)
    std /= len(loader.dataset)

    return mean, std
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=32, num_workers=0, shuffle=False)
    mean = 0.
    std = 0.
    for images, _ in loader:
        images = images.to(device)
        batch_samples = images.size(0)
        images = images.view(batch_samples, images.size(1), -1)
        mean += images.mean(2).sum(0)
        std += images.std(2).sum(0)
    mean /= len(loader.dataset)
    std /= len(loader.dataset)
    return mean, std
def mean_std ( dataset ) : loader = DataLoader ( dataset , batch_size = 32 , num_workers = 0 , shuffle = False ) mean = 0. std = 0. for images , _ in loader : images = images . to ( device ) batch_samples = images . size ( 0 ) images = images . view ( batch_samples , images . size ( 1 ) , - 1 ) mean += images . mean ( 2 ) . sum ( 0 ) std += images . std ( 2 ) . sum ( 0 ) mean /= len ( loader . dataset ) std /= len ( loader . dataset ) return mean , std
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