Note: Functions takingTensor
arguments can also take anything accepted bytf.convert_to_tensor
.
TensorFlow provides a set of functions to help manage the set of variables collected in the graph.
tf.global_variables
tf.local_variables
tf.model_variables
tf.trainable_variables
tf.moving_average_variables
tf.global_variables_initializer
tf.local_variables_initializer
tf.variables_initializer
tf.is_variable_initialized
tf.report_uninitialized_variables
tf.assert_variables_initialized
tf.assign
tf.assign_add
tf.assign_sub
tf.train.Saver
tf.train.latest_checkpoint
tf.train.get_checkpoint_state
tf.train.update_checkpoint_state
TensorFlow provides several classes and operations that you can use to create variables contingent on certain conditions.
tf.get_variable
tf.get_local_variable
tf.VariableScope
tf.variable_scope
tf.variable_op_scope
tf.get_variable_scope
tf.make_template
tf.no_regularizer
tf.constant_initializer
tf.random_normal_initializer
tf.truncated_normal_initializer
tf.random_uniform_initializer
tf.uniform_unit_scaling_initializer
tf.zeros_initializer
tf.ones_initializer
tf.orthogonal_initializer
The sparse update ops modify a subset of the entries in a dense Variable
, either overwriting the entries or adding / subtracting a delta. These are useful for training embedding models and similar lookup-based networks, since only a small subset of embedding vectors change in any given step.
Since a sparse update of a large tensor may be generated automatically during gradient computation (as in the gradient of tf.gather
), an tf.IndexedSlices
class is provided that encapsulates a set of sparse indices and values. IndexedSlices
objects are detected and handled automatically by the optimizers in most cases.
tf.scatter_update
tf.scatter_add
tf.scatter_sub
tf.scatter_mul
tf.scatter_div
tf.scatter_nd_update
tf.scatter_nd_add
tf.scatter_nd_sub
tf.sparse_mask
tf.IndexedSlices
© 2017 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_guides/python/state_ops