def batch_norm(in_tensor, phase_train, name, reuse=None, data_format='NHWC', center=True, scale=True):
"""
Batch normalization on convolutional maps.
Ref.: http://stackoverflow.com/questions/33949786/how-could-i-use-batch-normalization-in-tensorflow
Args:
x: Tensor, 4D BHWD input maps
n_out: integer, depth of input maps
phase_train: boolean tf.Varialbe, true indicates training phase
scope: string, variable scope
Return:
normed: batch-normalized maps
"""
axis = -1 if data_format == 'NHWC' else 1
with tf.variable_scope(name):
# return tf.contrib.layers.batch_norm(in_tensor, is_training=phase_train, scope=scope, reuse=reuse)
return tf.layers.batch_normalization(in_tensor, axis=axis, center=center, scale=scale, training=phase_train,
reuse=reuse, fused=True, momentum=0.99)
评论列表
文章目录