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

Method initialized_value

tensorflow/python/ops/variables.py:724–748  ·  view source on GitHub ↗

Returns the value of the initialized variable. You should use this instead of the variable itself to initialize another variable with a value that depends on the value of this variable. ```python # Initialize 'v' with a random tensor. v = tf.Variable(tf.random.truncated_normal(

(self)

Source from the content-addressed store, hash-verified

722 None, "Use Variable.read_value. Variables in 2.X are initialized "
723 "automatically both in eager and graph (inside tf.defun) contexts.")
724 def initialized_value(self):
725 """Returns the value of the initialized variable.
726
727 You should use this instead of the variable itself to initialize another
728 variable with a value that depends on the value of this variable.
729
730 ```python
731 # Initialize 'v' with a random tensor.
732 v = tf.Variable(tf.random.truncated_normal([10, 40]))
733 # Use `initialized_value` to guarantee that `v` has been
734 # initialized before its value is used to initialize `w`.
735 # The random values are picked only once.
736 w = tf.Variable(v.initialized_value() * 2.0)
737 ```
738
739 Returns:
740 A `Tensor` holding the value of this variable after its initializer
741 has run.
742 """
743 with ops.init_scope():
744 # optimize node placement policy in initialized_value stage.
745 with ops.colocate_with(self):
746 return control_flow_ops.cond(is_variable_initialized(self),
747 self.read_value,
748 lambda: self.initial_value)
749
750 @property
751 def initial_value(self):

Calls 3

colocate_withMethod · 0.80
is_variable_initializedFunction · 0.70
condMethod · 0.45