コード例 #1
0
 def while_loop_body(iteration, multipliers, inactive, old_inactive):
     """Performs one iteration of the projection."""
     del old_inactive  # Needed by the condition, but not the body.
     iteration += 1
     scale = standard_ops.minimum(
         0.0, (radius - standard_ops.reduce_sum(multipliers)) /
         standard_ops.maximum(1.0, standard_ops.reduce_sum(inactive)))
     multipliers = multipliers + (scale * inactive)
     new_inactive = standard_ops.cast(multipliers > 0, multipliers.dtype)
     multipliers = multipliers * new_inactive
     return (iteration, multipliers, new_inactive, inactive)
コード例 #2
0
 def while_loop_body(iteration, multipliers, inactive, old_inactive):
   """Performs one iteration of the projection."""
   del old_inactive  # Needed by the condition, but not the body.
   iteration += 1
   scale = standard_ops.minimum(
       0.0,
       (radius - standard_ops.reduce_sum(multipliers)) / standard_ops.maximum(
           1.0, standard_ops.reduce_sum(inactive)))
   multipliers += scale * inactive
   new_inactive = standard_ops.cast(multipliers > 0, multipliers.dtype)
   multipliers *= new_inactive
   return (iteration, multipliers, new_inactive, inactive)