tf.compat.v1.get_variable_scope  |  TensorFlow v2.16.1 (original) (raw)

tf.compat.v1.get_variable_scope

Stay organized with collections Save and categorize content based on your preferences.

Returns the current variable scope.

tf.compat.v1.get_variable_scope()

Migrate to TF2

Although it is a legacy compat.v1 api,tf.compat.v1.get_variable is compatible with eager execution and tf.function

However, to maintain variable-scope based variable reuse you will need to combine it withtf.compat.v1.keras.utils.track_tf1_style_variables. (Though it will behave as if reuse is always set to tf.compat.v1.AUTO_REUSE.)

See themigration guidefor more info.

The TF2 equivalent, if you are just trying to track variable name prefixes and not control get_variable-based variable reuse, would be to use tf.name_scope and capture the output of opening the scope (which represents the current name prefix).

For example:

x = tf.name_scope('foo') as current_scope:
  ...

Description

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.

Last updated 2024-04-26 UTC.