tf.variable_creator_scope  |  TensorFlow v2.16.1 (original) (raw)

tf.variable_creator_scope

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

Scope which defines a variable creation function to be used by variable().

@tf_contextlib.contextmanager tf.variable_creator_scope( variable_creator )

Used in the notebooks

Used in the guide
Validating correctness & numerical equivalence

variable_creator is expected to be a function with the following signature:

  def variable_creator(next_creator, **kwargs)

The creator is supposed to eventually call the next_creator to create a variable if it does want to create a variable and not call Variable or ResourceVariable directly. This helps make creators composable. A creator may choose to create multiple variables, return already existing variables, or simply register that a variable was created and defer to the next creators in line. Creators can also modify the keyword arguments seen by the next creators.

Custom getters in the variable scope will eventually resolve down to these custom creators when they do create variables.

The valid keyword arguments in kwds are:

This set may grow over time, so it's important the signature of creators is as mentioned above.

Args
variable_creator the passed creator
Yields
A scope in which the creator is active

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.