optimizer.py 文件源码

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

项目:tefla 作者: openAGI 项目源码 文件源码
def __init__(self,
                 opt,
                 vars_to_clip_dims,
                 max_norm,
                 use_locking=False,
                 colocate_clip_ops_with_vars=False,
                 name="VariableClipping"):
        """Construct a new clip-norm optimizer.

        Args:
          opt: The actual optimizer that will be used to compute and apply the
            gradients. Must be one of the Optimizer classes.
          vars_to_clip_dims: A dict with keys as Variables and values as lists
            of dimensions along which to compute the L2-norm.  See
            `tf.clip_by_norm` for more details.
          max_norm: The L2-norm to clip to, for all variables specified.
          use_locking: If `True` use locks for clip update operations.
          colocate_clip_ops_with_vars: If `True`, try colocating the clip norm
            ops with the corresponding variable.
          name: Optional name prefix for the operations created when applying
            gradients.  Defaults to "VariableClipping".
        """
        super(VariableClippingOptimizer, self).__init__(use_locking, name)
        self._opt = opt
        # Defensive copy of input dict
        self._vars_to_clip_dims = {
            var: clip_dims[:] for var, clip_dims in vars_to_clip_dims.items()}
        self._max_norm = max_norm
        self._colocate_clip_ops_with_vars = colocate_clip_ops_with_vars
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号