New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No way to re-enter previous name/variable-scoped context #1797
Comments
It is actually possible to re-enter a closed variable scope, as in the example below. with tf.variable_scope('test') as vscope: pass
with tf.variable_scope(vs) as vscope_:
assert vscope.name == vscope_.name However, the re-entered variable scope does not copy the reuse status of the original one. |
@gaohuazuo hmmm that assert statement returns True (as long as you are consistent about
with corresponding non-overlapping name-scopes in tensorboard. This is not changed by passing |
Anyway, if possible I think it would be useful to be able to access name-scope of a given variable....without writing a (simple but) hacky regex. The current approach I am using to build layers in a more functional manner does not lend itself to the workflow described above. |
I'll assign to lukasz, he may have code fixing this. |
I'm working on a CL/PR that at least adds the name scope to variable scope. Will report back here once that's in. |
…see tensorflow#1797, tensorflow#213.) In particular, this decouples the uniquification of variable scope names from the surrounding name scope. This is potentially a breaking change for models that rely on those names, but name_scope was never meant or designed to flow into variable scope names, so this bug must be corrected at some point. Change: 124986168
A recent CL correcting this is now live on master. It includes a unit test that re-enters a variable scope and the original name scope this variable scope was created in (by using the new .original_name_scope property). See here: variable_scope_test. Closing this now, please re-open or make a new issue if you find more problems! |
As far as I can tell, there is no way to re-enter the same name_scope or variable_scope (once closed) without the name being "unique-ified."
The example in the docs shows how to re-enter the original scope from within a nested scope - but not when context is closed.
Perhaps this could be solved by enabling access to the scope reference as
tf.Variable.scope
?Current hack-y workaround is to manually specify variable name as
"{}/name".format(previous_scope_name)
The text was updated successfully, but these errors were encountered: