tensorflow_tutorials_libs.activations

  • f1-f2=leak 這樣可以避免使用if判斷語句
"""Activations for TensorFlow.
Parag K. Mital, Jan 2016."""
import tensorflow as tf

def lrelu(x, leak=0.2, name="lrelu"):
    """Leaky rectifier.

    Parameters
    ----------
    x : Tensor
        The tensor to apply the nonlinearity to.
    leak : float, optional
        Leakage parameter.
    name : str, optional
        Variable scope to use.

    Returns
    -------
    x : Tensor
        Output of the nonlinearity.
    """
    with tf.variable_scope(name):
        f1 = 0.5 * (1 + leak)  # 0.6
        f2 = 0.5 * (1 - leak)  # 0.4
        return f1 * x + f2 * abs(x)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章