(name, shape, stddev, wd, use_xavier=True)
return var
Helper to create an initialized Variable with weight decay.

  Note that the Variable is initialized with a truncated normal distribution.
  A weight decay is added only if one is specified.

  Args:
    name: name of the variable
    shape: list of ints
    stddev: standard deviation of a truncated Gaussian
    wd: add L2Loss weight decay multiplied by this float. If None, weight
        decay is not added for this Variable.
    use_xavier: bool, whether to use xavier initializer

  Returns:
    Variable Tensor
Helper to create an initialized Variable with weight decay.
Helper to create an initialized Variable with weight decay .
def _variable_with_weight_decay(name, shape, stddev, wd, use_xavier=True):
    """Helper to create an initialized Variable with weight decay.

  Note that the Variable is initialized with a truncated normal distribution.
  A weight decay is added only if one is specified.

  Args:
    name: name of the variable
    shape: list of ints
    stddev: standard deviation of a truncated Gaussian
    wd: add L2Loss weight decay multiplied by this float. If None, weight
        decay is not added for this Variable.
    use_xavier: bool, whether to use xavier initializer

  Returns:
    Variable Tensor
  """
    if use_xavier:
        initializer = tf.contrib.layers.xavier_initializer()
    else:
        initializer = tf.truncated_normal_initializer(stddev=stddev)
    var = _variable_on_cpu(name, shape, initializer)
    if wd is not None:
        weight_decay = tf.multiply(tf.nn.l2_loss(var), wd, name="weight_loss")
        tf.add_to_collection("losses", weight_decay)
    return var
def _variable_with_weight_decay ( name , shape , stddev , wd , use_xavier = True ) : if use_xavier : initializer = tf . contrib . layers . xavier_initializer ( ) else : initializer = tf . truncated_normal_initializer ( stddev = stddev ) var = _variable_on_cpu ( name , shape , initializer ) if wd is not None : weight_decay = tf . multiply ( tf . nn . l2_loss ( var ) , wd , name = "weight_loss" ) tf . add_to_collection ( "losses" , weight_decay ) return var