You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As far as I know, there is currently no way to get the current value of a variable while ensuring that it has been initialized once. tf.Variable.initialized_value() has a dependency on the initializer that causes the variable to be reset to its initial value every time it is accessed. Using return tf.cond(tf.is_variable_initialized(variable), lambda: variable.value(), lambda: variable.initialized_value()) does not work since the true-branch of the conditional requires the variable to be initialized, even though the false-branch becomes active.
The text was updated successfully, but these errors were encountered:
This is one of snags in dependent variable initialization that can't be handled with initialized_value, see #4920 for discussion.
I used smart_initialize that rewrote the graph to automatically initialize the variable on first read, but with VariableV2 change, things changed so that now adding a control dependency in var/read on initializer causes a hang.
I think perhaps the way to fix it is to have add a piece of code that monkey-patch replaces tf.Variable class with a version that returns a Tensor which triggers variable initialization on first read
Automatically closing due to lack of recent activity. Please update the issue when new information becomes available, and we will reopen the issue. Thanks!
Uh oh!
There was an error while loading. Please reload this page.
As far as I know, there is currently no way to get the current value of a variable while ensuring that it has been initialized once. tf.Variable.initialized_value() has a dependency on the initializer that causes the variable to be reset to its initial value every time it is accessed. Using
return tf.cond(tf.is_variable_initialized(variable), lambda: variable.value(), lambda: variable.initialized_value())
does not work since the true-branch of the conditional requires the variable to be initialized, even though the false-branch becomes active.The text was updated successfully, but these errors were encountered: