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

Function update_bn_ema

tensorpack/models/_old_batch_norm.py:39–54  ·  view source on GitHub ↗
(xn, batch_mean, batch_var,
                  moving_mean, moving_var, decay, internal_update)

Source from the content-addressed store, hash-verified

37
38
39def update_bn_ema(xn, batch_mean, batch_var,
40 moving_mean, moving_var, decay, internal_update):
41 update_op1 = moving_averages.assign_moving_average(
42 moving_mean, batch_mean, decay, zero_debias=False,
43 name='mean_ema_op')
44 update_op2 = moving_averages.assign_moving_average(
45 moving_var, batch_var, decay, zero_debias=False,
46 name='var_ema_op')
47
48 if internal_update:
49 with tf.control_dependencies([update_op1, update_op2]):
50 return tf.identity(xn, name='output')
51 else:
52 tf.add_to_collection(tf.GraphKeys.UPDATE_OPS, update_op1)
53 tf.add_to_collection(tf.GraphKeys.UPDATE_OPS, update_op2)
54 return tf.identity(xn, name='output')
55
56
57@layer_register()

Callers 1

BatchNormFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected