Created
December 8, 2017 14:24
-
-
Save imironhead/af2dc12a953cc953bed6e1c5f3c3d2dc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def instance_norm(flow): | |
""" | |
arXiv:1607.08022v2 | |
""" | |
with tf.variable_scope('inst_norm'): | |
depth = flow.get_shape()[3] | |
scale = tf.get_variable( | |
'scale', | |
[depth], | |
initializer=tf.random_normal_initializer(1.0, 0.02)) | |
shift = tf.get_variable( | |
'shift', | |
[depth], | |
initializer=tf.constant_initializer(0.0)) | |
mean, variance = tf.nn.moments(flow, axes=[1, 2], keep_dims=True) | |
flow = (flow - mean) / tf.sqrt(variance + 1e-5) | |
return scale * flow + shift |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment