activation.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:tfkaldi 作者: vrenkens 项目源码 文件源码
def _apply_func(self, activations, is_training, reuse):
        '''
        apply own functionality
        Args:
            activations: the ioutputs to the wrapped activation function
            is_training: whether or not the network is in training mode
            reuse: wheter or not the variables in the network should be reused
        Returns:
            the output to the activation function
        '''

        with tf.variable_scope('l2_norm', reuse=reuse):
            #compute the mean squared value
            sig = tf.reduce_mean(tf.square(activations), 1, keep_dims=True)

            #divide the input by the mean squared value
            normalized = activations/sig

            #if the mean squared value is larger then one select the normalized
            #value otherwise select the unnormalised one
            return tf.select(tf.greater(tf.reshape(sig, [-1]), 1),
                             normalized, activations)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号