(compute, dataset, sample_size=None, batch_size=10,
        cachefile=None, **kwargs)
Computes cross covariance statistics for a large data sample that can
    be computed from a dataset.  The compute function should return one
    batch of samples as pair of [(sample, unitA), (sample, unitB)] tensors.
Computes cross covariance statistics for a large data sample that can
    be computed from a dataset.  The compute function should return one
    batch of samples as pair of [(sample, unitA), (sample, unitB)] tensors.
Computes cross covariance statistics for a large data sample that can be computed from a dataset . The compute function should return one batch of samples as pair of [ ( sample unitA ) ( sample unitB ) ] tensors .
def tally_cross_covariance(compute, dataset, sample_size=None, batch_size=10,
        cachefile=None, **kwargs):
    '''
    Computes cross covariance statistics for a large data sample that can
    be computed from a dataset.  The compute function should return one
    batch of samples as pair of [(sample, unitA), (sample, unitB)] tensors.
    '''
    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.RunningCrossCovariance(state=cached_state)
        loader = make_loader(dataset, sample_size, batch_size, **kwargs)
        rcov = runningstats.RunningCrossCovariance()
        for batch in pbar(loader):
            sampleA, sampleB = call_compute(compute, batch)
            rcov.add(sampleA, sampleB)
        rcov.to_('cpu')
        save_cached_state(cachefile, rcov, args)
        return rcov
def tally_cross_covariance ( 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 . RunningCrossCovariance ( state = cached_state ) loader = make_loader ( dataset , sample_size , batch_size , * * kwargs ) rcov = runningstats . RunningCrossCovariance ( ) for batch in pbar ( loader ) : sampleA , sampleB = call_compute ( compute , batch ) rcov . add ( sampleA , sampleB ) rcov . to_ ( 'cpu' ) save_cached_state ( cachefile , rcov , args ) return rcov