MCPcopy Create free account
hub / github.com/MrNothing/AI-Blocks / batchnorm

Function batchnorm

Sources/scripts/function.py:37–48  ·  view source on GitHub ↗
(input)

Source from the content-addressed store, hash-verified

35 return tf.nn.relu(x)
36
37def batchnorm(input):
38 with tf.variable_scope(self.name):
39 # this block looks like it has 3 inputs on the graph unless we do this
40 input = tf.identity(input)
41
42 channels = input.get_shape()[3]
43 offset = tf.get_variable("offset", [channels], dtype=tf.float32, initializer=tf.zeros_initializer())
44 scale = tf.get_variable("scale", [channels], dtype=tf.float32, initializer=tf.random_normal_initializer(1.0, 0.02))
45 mean, variance = tf.nn.moments(input, axes=[0, 1, 2], keep_dims=False)
46 variance_epsilon = 1e-5
47 normalized = tf.nn.batch_normalization(input, mean, variance, offset, scale, variance_epsilon=variance_epsilon)
48 return normalized
49
50def lrelu(x):
51 a = self.a

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected