def get_variable_scope_name(value):
"""Returns the name of the variable scope indicated by the given value.
Args:
value: String, variable scope, or object with `variable_scope` attribute
(e.g., Sonnet module).
Returns:
The name (a string) of the corresponding variable scope.
Raises:
ValueError: If `value` does not identify a variable scope.
"""
# If the object has a "variable_scope" property, use it.
value = getattr(value, "variable_scope", value)
if isinstance(value, tf.VariableScope):
return value.name
elif isinstance(value, six.string_types):
return value
else:
raise ValueError("Not a variable scope: {}".format(value))
评论列表
文章目录