MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / internal_update_bn_ema

Function internal_update_bn_ema

tensorpack/models/batch_norm.py:47–60  ·  view source on GitHub ↗
(xn, batch_mean, batch_var,
                           moving_mean, moving_var, decay)

Source from the content-addressed store, hash-verified

45
46
47def internal_update_bn_ema(xn, batch_mean, batch_var,
48 moving_mean, moving_var, decay):
49 update_op1 = moving_averages.assign_moving_average(
50 moving_mean, batch_mean, decay, zero_debias=False,
51 name='mean_ema_op')
52 update_op2 = moving_averages.assign_moving_average(
53 moving_var, batch_var, decay, zero_debias=False,
54 name='var_ema_op')
55
56 # When sync_statistics is True, always enable internal_update.
57 # Otherwise the update ops (only executed on main tower)
58 # will hang when some BatchNorm layers are unused (https://github.com/tensorpack/tensorpack/issues/1078)
59 with tf.control_dependencies([update_op1, update_op2]):
60 return tf.identity(xn, name='output')
61
62
63def get_sync_bn_mean_var(inputs, red_axis, sync_statistics):

Callers 1

BatchNormFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…