Skip to content

Commit

Permalink
ENH: added support for batch norm and layer norm with default params
Browse files Browse the repository at this point in the history
  • Loading branch information
sudnya committed Apr 5, 2017
1 parent ac9ad27 commit 3b8b865
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions network.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ def init_inference(self, config):
else:
acts = _rnn(acts, rnn_dim, cell_type)

#TODO: for now assume only one batch norm layer allowed at a time
bn_conf = config.get('batch-norm', None)
if bn_conf is not None:
acts = tf.contrib.layers.batch_norm(acts, decay=0.9, center=True,
scale=True, epsilon=1e-8, activation_fn=None,
is_training=True)

ln_conf = config.get('layer-norm', None)
if ln_conf is not None:
acts = tf.contrib.layers.layer_norm(acts, center=True,
scale=True, activation_fn=None)
# Reduce the time-dimension to make a single prediction
acts = tf.reduce_mean(acts, axis=1)

Expand Down

0 comments on commit 3b8b865

Please sign in to comment.