Python tensorflow.python.ops.state_ops.variable_op_v2() Examples
The following are 1
code examples of tensorflow.python.ops.state_ops.variable_op_v2().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
tensorflow.python.ops.state_ops
, or try the search function
.
Example #1
Source File: graph_context.py From tensorlang with Apache License 2.0 | 5 votes |
def define_local(self, name, value): if name in self._locals: raise Exception("Local already defined: %s" % name) should_wrap_in_var = False if self._wrap_locals_in_vars: if isinstance(value, tf.Tensor): should_wrap_in_var = True # HACK(adamb) Unwrapping in here really isn't great, since auto-unwrapping can create unexpected behavior. if isinstance(value, RetvalBag) and value.len() == 1: if isinstance(value.get(None), tf.Tensor): should_wrap_in_var = True value = value.get(None) if should_wrap_in_var: variable = state_ops.variable_op_v2( value.get_shape(), value.dtype.base_dtype) with tf.control_dependencies(None): value = tf.identity( tf.cond( tf.is_variable_initialized(variable), lambda: variable, lambda: tf.assign(variable, value) ) ) print("value", value) self._locals[name] = value return value