regularizers.py 文件源码

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

项目:DropNeuron 作者: panweihit 项目源码 文件源码
def sum_regularizer(regularizer_list):
  """Returns a function that applies the sum of multiple regularizers.

  Args:
    regularizer_list: A list of regularizers to apply.

  Returns:
    A function with signature `sum_reg(weights, name=None)` that applies the
    sum of all the input regularizers.
  """
  regularizer_list = [reg for reg in regularizer_list if reg is not None]
  if not regularizer_list:
    return None

  def sum_reg(weights, name=None):
    """Applies the sum of all the input regularizers."""
    with ops.op_scope([weights], name, 'sum_regularizer') as scope:
      regularizer_tensors = [reg(weights) for reg in regularizer_list]
      return math_ops.add_n(regularizer_tensors, name=scope)

  return sum_reg
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号