()
| 74 | # apply moving average for mean and var when train on batch |
| 75 | ema = tf.train.ExponentialMovingAverage(decay=0.5) |
| 76 | def mean_var_with_update(): |
| 77 | ema_apply_op = ema.apply([fc_mean, fc_var]) |
| 78 | with tf.control_dependencies([ema_apply_op]): |
| 79 | return tf.identity(fc_mean), tf.identity(fc_var) |
| 80 | mean, var = mean_var_with_update() |
| 81 | |
| 82 | Wx_plus_b = tf.nn.batch_normalization(Wx_plus_b, mean, var, shift, scale, epsilon) |