(compute, dataset, sample_size=None, batch_size=10,
        multi_label_axis=None, cachefile=None, **kwargs)
Computes bincount totals 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 bincount totals 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 bincount totals 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_bincount(compute, dataset, sample_size=None, batch_size=10,
        multi_label_axis=None, cachefile=None, **kwargs):
    '''
    Computes bincount totals 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.RunningBincount(state=cached_state)
        loader = make_loader(dataset, sample_size, batch_size, **kwargs)
        rbc = runningstats.RunningBincount()
        for batch in pbar(loader):
            sample = call_compute(compute, batch)
            if multi_label_axis:
                multilabel = sample.shape[multi_label_axis]
                size = sample.numel() // multilabel
            else:
                size = None
            rbc.add(sample, size=size)
        rbc.to_('cpu')
        save_cached_state(cachefile, rbc, args)
        return rbc
def tally_bincount ( compute , dataset , sample_size = None , batch_size = 10 , multi_label_axis = None , 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 . RunningBincount ( state = cached_state ) loader = make_loader ( dataset , sample_size , batch_size , * * kwargs ) rbc = runningstats . RunningBincount ( ) for batch in pbar ( loader ) : sample = call_compute ( compute , batch ) if multi_label_axis : multilabel = sample . shape [ multi_label_axis ] size = sample . numel ( ) // multilabel else : size = None rbc . add ( sample , size = size ) rbc . to_ ( 'cpu' ) save_cached_state ( cachefile , rbc , args ) return rbc