model_variable

tfsnippet.utils.model_variable(name, shape=None, dtype=None, initializer=None, regularizer=None, constraint=None, trainable=True, collections=None, **kwargs)

Get or create a model variable.

When the variable is created, it will be added to both GLOBAL_VARIABLES and MODEL_VARIABLES collection.

Parameters:
  • name – Name of the variable.
  • shape – Shape of the variable.
  • dtype – Data type of the variable.
  • initializer – Initializer of the variable.
  • regularizer – Regularizer of the variable.
  • constraint – Constraint of the variable.
  • trainable (bool) – Whether or not the variable is trainable?
  • collections – In addition to GLOBAL_VARIABLES and MODEL_VARIABLES, also add the variable to these collections.
  • **kwargs – Other named arguments passed to tf.get_variable().
Returns:

The variable.

Return type:

tf.Variable