44ae6129731ee1d225db8a5f1bafea5fd4b9b542,open_seq2seq/parts/transformer/common.py,LayerNormalization,call,#LayerNormalization#Any#,70

Before Change


      variance = tf.reduce_mean(tf.abs(x), axis=[-1], keepdims=True)
      norm_x = tf.div(x , variance + self.epsilon)
    else:
      print("WARNING: Layer norm: type ", self.norm_type, "not supported")
      norm_x = x

    y = norm_x * self.scale + self.bias
    if dtype == tf.float16:

After Change


    if self.norm_type=="layernorm_L2":
      epsilon = self.epsilon
      dtype = x.dtype
      x = tf.cast(x=x, dtype=tf.float32)
      mean = tf.reduce_mean(x, axis=[-1], keepdims=True)
      variance = tf.reduce_mean(tf.square(x - mean), axis=[-1], keepdims=True)
      norm_x = (x - mean) * tf.rsqrt(variance + epsilon)
      result = norm_x * self.scale + self.bias
      return tf.cast(x=result, dtype=dtype)

    else: //if self.norm_type=="layernorm_L1":
      dtype = x.dtype
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: NVIDIA/OpenSeq2Seq
Commit Name: 44ae6129731ee1d225db8a5f1bafea5fd4b9b542
Time: 2019-02-06
Author: boris.ginsburg@gmail.com
File Name: open_seq2seq/parts/transformer/common.py
Class Name: LayerNormalization
Method Name: call


Project Name: hanxiao/bert-as-service
Commit Name: cf3dc776a4ac3005744f9ea531c244d7aeb765f8
Time: 2019-01-17
Author: hanhxiao@tencent.com
File Name: server/bert_serving/server/graph.py
Class Name:
Method Name: optimize_graph


Project Name: NifTK/NiftyNet
Commit Name: f6b5e2412d4912caa43384d97b90287b2c4e218f
Time: 2017-08-18
Author: wenqi.li@ucl.ac.uk
File Name: niftynet/layer/loss.py
Class Name:
Method Name: wasserstein_generalised_dice_loss