MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _init_from_args

Method _init_from_args

tensorflow/python/ops/control_flow_ops.py:1439–1472  ·  view source on GitHub ↗

Creates a new `WhileContext` from arguments. Args: maximum_iterations: Optional upper bound on number of loop iterations. parallel_iterations: The number of iterations allowed to run in parallel. back_prop: Whether backprop is enabled for this while loop. swap_memory: Wh

(self, maximum_iterations, parallel_iterations, back_prop,
                      swap_memory, name)

Source from the content-addressed store, hash-verified

1437 self._grad_state = grad_state
1438
1439 def _init_from_args(self, maximum_iterations, parallel_iterations, back_prop,
1440 swap_memory, name):
1441 """Creates a new `WhileContext` from arguments.
1442
1443 Args:
1444 maximum_iterations: Optional upper bound on number of loop iterations.
1445 parallel_iterations: The number of iterations allowed to run in parallel.
1446 back_prop: Whether backprop is enabled for this while loop.
1447 swap_memory: Whether GPU-CPU memory swap is enabled for this loop.
1448 name: Optional name prefix for the returned tensors.
1449
1450 Raises:
1451 ValueError: If `parallel_iterations` has invalid value.
1452 """
1453 if not isinstance(parallel_iterations, int) or (parallel_iterations <= 0):
1454 raise ValueError("`parallel_iterations` must be a positive integer: "
1455 "%s" % parallel_iterations)
1456 self._name = ops.get_default_graph().unique_name(name)
1457 self._maximum_iterations = maximum_iterations
1458 self._parallel_iterations = parallel_iterations
1459 self._back_prop = back_prop
1460 self._swap_memory = swap_memory
1461 # We use this node to control constants created by the pred lambda.
1462 self._pivot_for_pred = None
1463 # We use this node to control constants created by the body lambda.
1464 self._pivot_for_body = None
1465 # The boolean tensor for loop termination condition. Used in code
1466 # generation for gradient computation
1467 self._pivot = None
1468 # The list of exit tensors for loop variables.
1469 self._loop_exits = []
1470 # The list of enter tensors for loop variables.
1471 self._loop_enters = []
1472 self._graph = ops.get_default_graph()
1473
1474 def _init_from_proto(self, context_def, import_scope=None):
1475 """Creates a new `WhileContext` from protocol buffer.

Callers 1

__init__Method · 0.95

Calls 1

unique_nameMethod · 0.80

Tested by

no test coverage detected