(compute, dataset, sample_size=None, batch_size=10,
        cachefile=None, **kwargs)
Computes unitwise mean and variance stats for a large data sample that
    can be computed from a dataset.  The compute function should return one
    batch of samples as a (sample, unit)-dimension tensor.
Computes unitwise mean and variance stats for a large data sample that
    can be computed from a dataset.  The compute function should return one
    batch of samples as a (sample, unit)-dimension tensor.
Computes unitwise mean and variance stats for a large data sample that can be computed from a dataset . The compute function should return one batch of samples as a ( sample unit ) - dimension tensor .
def tally_mean(compute, dataset, sample_size=None, batch_size=10,
        cachefile=None, **kwargs):
    '''
    Computes unitwise mean and variance stats for a large data sample that
    can be computed from a dataset.  The compute function should return one
    batch of samples as a (sample, unit)-dimension tensor.
    '''
    with torch.no_grad():
        args = dict(sample_size=sample_size)
        cached_state = load_cached_state(cachefile, args)
        if cached_state is not None:
            return runningstats.RunningVariance(state=cached_state)
        loader = make_loader(dataset, sample_size, batch_size, **kwargs)
        rv = runningstats.RunningVariance()
        for batch in pbar(loader):
            sample = call_compute(compute, batch)
            rv.add(sample)
        rv.to_('cpu')
        save_cached_state(cachefile, rv, args)
        return rv
def tally_mean ( compute , dataset , sample_size = None , batch_size = 10 , cachefile = None , * * kwargs ) : with torch . no_grad ( ) : args = dict ( sample_size = sample_size ) cached_state = load_cached_state ( cachefile , args ) if cached_state is not None : return runningstats . RunningVariance ( state = cached_state ) loader = make_loader ( dataset , sample_size , batch_size , * * kwargs ) rv = runningstats . RunningVariance ( ) for batch in pbar ( loader ) : sample = call_compute ( compute , batch ) rv . add ( sample ) rv . to_ ( 'cpu' ) save_cached_state ( cachefile , rv , args ) return rv