(unused_sv, sess, m, dataset, unused_hparams)
Averages over mini batches for population statistics for batch norm.
Averages over mini batches for population statistics for batch norm.
Averages over mini batches for population statistics for batch norm .
def estimate_popstats(unused_sv, sess, m, dataset, unused_hparams):
  """Averages over mini batches for population statistics for batch norm."""
  print('Estimating population statistics...')
  tfbatchstats, tfpopstats = list(zip(*list(m.popstats_by_batchstat.items())))

  nepochs = 3
  nppopstats = [lib_util.AggregateMean('') for _ in tfpopstats]
  for _ in range(nepochs):
    batches = (
        dataset.get_featuremaps().batches(size=m.batch_size, shuffle=True))
    for unused_step, batch in enumerate(batches):
      feed_dict = batch.get_feed_dict(m.placeholders)
      npbatchstats = sess.run(tfbatchstats, feed_dict=feed_dict)
      for nppopstat, npbatchstat in zip(nppopstats, npbatchstats):
        nppopstat.add(npbatchstat)
  nppopstats = [nppopstat.mean for nppopstat in nppopstats]

  _print_popstat_info(tfpopstats, nppopstats)

  # Update tfpopstat variables.
  for unused_j, (tfpopstat, nppopstat) in enumerate(
      zip(tfpopstats, nppopstats)):
    tfpopstat.load(nppopstat)
def estimate_popstats ( unused_sv , sess , m , dataset , unused_hparams ) : print ( 'Estimating population statistics...' ) tfbatchstats , tfpopstats = list ( zip ( * list ( m . popstats_by_batchstat . items ( ) ) ) ) nepochs = 3 nppopstats = [ lib_util . AggregateMean ( '' ) for _ in tfpopstats ] for _ in range ( nepochs ) : batches = ( dataset . get_featuremaps ( ) . batches ( size = m . batch_size , shuffle = True ) ) for unused_step , batch in enumerate ( batches ) : feed_dict = batch . get_feed_dict ( m . placeholders ) npbatchstats = sess . run ( tfbatchstats , feed_dict = feed_dict ) for nppopstat , npbatchstat in zip ( nppopstats , npbatchstats ) : nppopstat . add ( npbatchstat ) nppopstats = [ nppopstat . mean for nppopstat in nppopstats ] _print_popstat_info ( tfpopstats , nppopstats ) # Update tfpopstat variables. for unused_j , ( tfpopstat , nppopstat ) in enumerate ( zip ( tfpopstats , nppopstats ) ) : tfpopstat . load ( nppopstat )