How to get the currently active tf.variable_scope in TensorFlow?
Asked Answered
G

1

5

I wrote a convenience API to define my models in TensorFlow that exposes a scope object. Now I want to verify that the user actually enters the scope before adding operations. How to get the name of the currently active tf.variable_scope in TensorFlow?

Gahl answered 17/7, 2016 at 14:41 Comment(0)
D
11

You can use tf.get_variable_scope() to get the currently active scope:

using tensorflow as tf
with tf.variable_scope("my_scope"):
  print(tf.get_variable_scope().name)

This will print "my_scope"

Diacaustic answered 17/7, 2016 at 15:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.