当前位置: 首页>>代码示例>>Python>>正文


Python control_flow_ops.IsLoopExit方法代码示例

本文整理汇总了Python中tensorflow.python.ops.control_flow_ops.IsLoopExit方法的典型用法代码示例。如果您正苦于以下问题:Python control_flow_ops.IsLoopExit方法的具体用法?Python control_flow_ops.IsLoopExit怎么用?Python control_flow_ops.IsLoopExit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tensorflow.python.ops.control_flow_ops的用法示例。


在下文中一共展示了control_flow_ops.IsLoopExit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _UpdatePendingAndEnqueueReady

# 需要导入模块: from tensorflow.python.ops import control_flow_ops [as 别名]
# 或者: from tensorflow.python.ops.control_flow_ops import IsLoopExit [as 别名]
def _UpdatePendingAndEnqueueReady(grads, op, queue, pending_count, loop_state):
  """Update pending count for the inputs of op and enqueue ready ops."""
  for x in op.inputs:
    # pylint: disable=protected-access
    pending_count[x.op._id] -= 1
    ready = (pending_count[x.op._id] == 0)
    if loop_state and not ready:
      ready = (pending_count[x.op._id] > 0 and
               control_flow_ops.IsLoopSwitch(x.op))
    # pylint: enable=protected-access
    if ready:
      if control_flow_ops.IsLoopExit(x.op):
        # if x is an exit without real gradient, defer processing them.
        grad_state = loop_state.GetGradState(x.op, before=False)
        grad_state.deferred_exits.append(x)
        grad_state.pending_exits_count -= 1
        if grad_state.pending_exits_count == 0:
          # We now have all the exits so process them.
          has_real_grad = False
          for y in grad_state.deferred_exits:
            if _HasAnyNotNoneGrads(grads, y.op):
              has_real_grad = True
              queue.append(y.op)
            else:
              grad_state.unused_exits.append(y)
          if has_real_grad:
            # For an unused exit, if it has floating-point outputs, backprop
            # a zero gradient. Otherwise, just ignore it.
            for y in grad_state.unused_exits:
              if _IsTrainable(y):
                _SetGrad(grads, y, loop_state.ZerosLikeForExit(y))
              queue.append(y.op)
          else:
            # All exits are "unused" so use None as gradient.
            for y in grad_state.unused_exits:
              queue.append(y.op)
      else:
        queue.append(x.op) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:40,代码来源:gradients_impl.py


注:本文中的tensorflow.python.ops.control_flow_ops.IsLoopExit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。