tf.compat.v1.ReaderBase Base class for different Reader types, that produce a record every step.
tf.compat.v1.ReaderBase(
    reader_ref, supports_serialize=False
)
 Conceptually, Readers convert string 'work units' into records (key, value pairs). Typically the 'work units' are filenames and the records are extracted from the contents of those files. We want a single record produced per step, but a work unit can correspond to many records. Therefore we introduce some decoupling using a queue. The queue contains the work units and the Reader dequeues from the queue when it is asked to produce a record (via Read()) but it has finished the last work unit.

 Args
  reader_ref   The operation that implements the reader.
  supports_serialize   True if the reader implementation can serialize its state.

 Raises
  RuntimeError   If eager execution is enabled.    Eager Compatibility Readers are not compatible with eager execution. Instead, please use tf.data to get data into your model.

 Attributes
  reader_ref   Op that implements the reader.
  supports_serialize   Whether the Reader implementation can serialize its state.    Methods num_records_produced View source
num_records_produced(
    name=None
)
 Returns the number of records this reader has produced. This is the same as the number of Read executions that have succeeded.

 Args
  name   A name for the operation (optional).

 Returns   An int64 Tensor.
 num_work_units_completed View source
num_work_units_completed(
    name=None
)
 Returns the number of work units this reader has finished processing.

 Args
  name   A name for the operation (optional).

 Returns   An int64 Tensor.
 read View source
read(
    queue, name=None
)
 Returns the next record (key, value) pair produced by a reader. Will dequeue a work unit from queue if necessary (e.g. when the Reader needs to start reading from a new file since it has finished with the previous file).

 Args
  queue   A Queue or a mutable string Tensor representing a handle to a Queue, with string work items.
  name   A name for the operation (optional).

 Returns   A tuple of Tensors (key, value).     key   A string scalar Tensor.
  value   A string scalar Tensor.    read_up_to View source
read_up_to(
    queue, num_records, name=None
)
 Returns up to num_records (key, value) pairs produced by a reader. Will dequeue a work unit from queue if necessary (e.g., when the Reader needs to start reading from a new file since it has finished with the previous file). It may return less than num_records even before the last batch.

 Args
  queue   A Queue or a mutable string Tensor representing a handle to a Queue, with string work items.
  num_records   Number of records to read.
  name   A name for the operation (optional).

 Returns   A tuple of Tensors (keys, values).     keys   A 1-D string Tensor.
  values   A 1-D string Tensor.    reset View source
reset(
    name=None
)
 Restore a reader to its initial clean state.

 Args
  name   A name for the operation (optional).

 Returns   The created Operation.
 restore_state View source
restore_state(
    state, name=None
)
 Restore a reader to a previously saved state. Not all Readers support being restored, so this can produce an Unimplemented error.

 Args
  state   A string Tensor. Result of a SerializeState of a Reader with matching type.
  name   A name for the operation (optional).

 Returns   The created Operation.
 serialize_state View source
serialize_state(
    name=None
)
 Produce a string tensor that encodes the state of a reader. Not all Readers support being serialized, so this can produce an Unimplemented error.

 Args
  name   A name for the operation (optional).

 Returns   A string Tensor.


tf.compat.v1.reduce_all Computes the "logical and" of elements across dimensions of a tensor. (deprecated arguments)  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.math.reduce_all
tf.compat.v1.reduce_all(
    input_tensor, axis=None, keepdims=None, name=None, reduction_indices=None,
    keep_dims=None
)
 Warning: SOME ARGUMENTS ARE DEPRECATED: (keep_dims). They will be removed in a future version. Instructions for updating: keep_dims is deprecated, use keepdims instead Reduces input_tensor along the dimensions given in axis. Unless keepdims is true, the rank of the tensor is reduced by 1 for each of the entries in axis, which must be unique. If keepdims is true, the reduced dimensions are retained with length 1. If axis is None, all dimensions are reduced, and a tensor with a single element is returned. For example: x = tf.constant([[True,  True], [False, False]])
tf.reduce_all(x)  # False
tf.reduce_all(x, 0)  # [False, False]
tf.reduce_all(x, 1)  # [True, False]

 Args
  input_tensor   The boolean tensor to reduce.
  axis   The dimensions to reduce. If None (the default), reduces all dimensions. Must be in the range [-rank(input_tensor), rank(input_tensor)).
  keepdims   If true, retains reduced dimensions with length 1.
  name   A name for the operation (optional).
  reduction_indices   The old (deprecated) name for axis.
  keep_dims   Deprecated alias for keepdims.

 Returns   The reduced tensor.
 Numpy Compatibility Equivalent to np.all


tf.compat.v1.reduce_any Computes the "logical or" of elements across dimensions of a tensor. (deprecated arguments)  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.math.reduce_any
tf.compat.v1.reduce_any(
    input_tensor, axis=None, keepdims=None, name=None, reduction_indices=None,
    keep_dims=None
)
 Warning: SOME ARGUMENTS ARE DEPRECATED: (keep_dims). They will be removed in a future version. Instructions for updating: keep_dims is deprecated, use keepdims instead Reduces input_tensor along the dimensions given in axis. Unless keepdims is true, the rank of the tensor is reduced by 1 for each of the entries in axis, which must be unique. If keepdims is true, the reduced dimensions are retained with length 1. If axis is None, all dimensions are reduced, and a tensor with a single element is returned. For example: x = tf.constant([[True,  True], [False, False]])
tf.reduce_any(x)  # True
tf.reduce_any(x, 0)  # [True, True]
tf.reduce_any(x, 1)  # [True, False]

 Args
  input_tensor   The boolean tensor to reduce.
  axis   The dimensions to reduce. If None (the default), reduces all dimensions. Must be in the range [-rank(input_tensor), rank(input_tensor)).
  keepdims   If true, retains reduced dimensions with length 1.
  name   A name for the operation (optional).
  reduction_indices   The old (deprecated) name for axis.
  keep_dims   Deprecated alias for keepdims.

 Returns   The reduced tensor.
 Numpy Compatibility Equivalent to np.any


tf.compat.v1.reduce_join Joins all strings into a single string, or joins along an axis.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.strings.reduce_join
tf.compat.v1.reduce_join(
    inputs, axis=None, keep_dims=None, separator='', name=None,
    reduction_indices=None, keepdims=None
)

tf.strings.reduce_join([['abc','123'],
                        ['def','456']]).numpy()
b'abc123def456'
tf.strings.reduce_join([['abc','123'],
                        ['def','456']], axis=-1).numpy()
array([b'abc123', b'def456'], dtype=object)
tf.strings.reduce_join([['abc','123'],
                        ['def','456']],
                       axis=-1,
                       separator=" ").numpy()
array([b'abc 123', b'def 456'], dtype=object)

 Args
  inputs   A tf.string tensor.
  axis   Which axis to join along. The default behavior is to join all elements, producing a scalar.
  keepdims   If true, retains reduced dimensions with length 1.
  separator   a string added between each string being joined.
  name   A name for the operation (optional).

 Returns   A tf.string tensor.


tf.compat.v1.reduce_logsumexp Computes log(sum(exp(elements across dimensions of a tensor))). (deprecated arguments)  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.math.reduce_logsumexp
tf.compat.v1.reduce_logsumexp(
    input_tensor, axis=None, keepdims=None, name=None, reduction_indices=None,
    keep_dims=None
)
 Warning: SOME ARGUMENTS ARE DEPRECATED: (keep_dims). They will be removed in a future version. Instructions for updating: keep_dims is deprecated, use keepdims instead Reduces input_tensor along the dimensions given in axis. Unless keepdims is true, the rank of the tensor is reduced by 1 for each of the entries in axis, which must be unique. If keepdims is true, the reduced dimensions are retained with length 1. If axis has no entries, all dimensions are reduced, and a tensor with a single element is returned. This function is more numerically stable than log(sum(exp(input))). It avoids overflows caused by taking the exp of large inputs and underflows caused by taking the log of small inputs. For example: x = tf.constant([[0., 0., 0.], [0., 0., 0.]])
tf.reduce_logsumexp(x)  # log(6)
tf.reduce_logsumexp(x, 0)  # [log(2), log(2), log(2)]
tf.reduce_logsumexp(x, 1)  # [log(3), log(3)]
tf.reduce_logsumexp(x, 1, keepdims=True)  # [[log(3)], [log(3)]]
tf.reduce_logsumexp(x, [0, 1])  # log(6)

 Args
  input_tensor   The tensor to reduce. Should have numeric type.
  axis   The dimensions to reduce. If None (the default), reduces all dimensions. Must be in the range [-rank(input_tensor), rank(input_tensor)).
  keepdims   If true, retains reduced dimensions with length 1.
  name   A name for the operation (optional).
  reduction_indices   The old (deprecated) name for axis.
  keep_dims   Deprecated alias for keepdims.

 Returns   The reduced tensor.


tf.compat.v1.reduce_max Computes the maximum of elements across dimensions of a tensor. (deprecated arguments)  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.math.reduce_max
tf.compat.v1.reduce_max(
    input_tensor, axis=None, keepdims=None, name=None, reduction_indices=None,
    keep_dims=None
)
 Warning: SOME ARGUMENTS ARE DEPRECATED: (keep_dims). They will be removed in a future version. Instructions for updating: keep_dims is deprecated, use keepdims instead Reduces input_tensor along the dimensions given in axis. Unless keepdims is true, the rank of the tensor is reduced by 1 for each of the entries in axis, which must be unique. If keepdims is true, the reduced dimensions are retained with length 1. If axis is None, all dimensions are reduced, and a tensor with a single element is returned.

 Args
  input_tensor   The tensor to reduce. Should have real numeric type.
  axis   The dimensions to reduce. If None (the default), reduces all dimensions. Must be in the range [-rank(input_tensor), rank(input_tensor)).
  keepdims   If true, retains reduced dimensions with length 1.
  name   A name for the operation (optional).
  reduction_indices   The old (deprecated) name for axis.
  keep_dims   Deprecated alias for keepdims.

 Returns   The reduced tensor.
 Numpy Compatibility Equivalent to np.max


tf.compat.v1.reduce_mean Computes the mean of elements across dimensions of a tensor.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.math.reduce_mean
tf.compat.v1.reduce_mean(
    input_tensor, axis=None, keepdims=None, name=None, reduction_indices=None,
    keep_dims=None
)
 Reduces input_tensor along the dimensions given in axis by computing the mean of elements across the dimensions in axis. Unless keepdims is true, the rank of the tensor is reduced by 1 for each the entries in axis, which must be unique. If keepdims is true, the reduced dimensions are retained with length 1. If axis is None, all dimensions are reduced, and a tensor with a single element is returned. For example:
x = tf.constant([[1., 1.], [2., 2.]])
tf.reduce_mean(x)
<tf.Tensor: shape=(), dtype=float32, numpy=1.5>
tf.reduce_mean(x, 0)
<tf.Tensor: shape=(2,), dtype=float32, numpy=array([1.5, 1.5], dtype=float32)>
tf.reduce_mean(x, 1)
<tf.Tensor: shape=(2,), dtype=float32, numpy=array([1., 2.], dtype=float32)>

 Args
  input_tensor   The tensor to reduce. Should have numeric type.
  axis   The dimensions to reduce. If None (the default), reduces all dimensions. Must be in the range [-rank(input_tensor), rank(input_tensor)).
  keepdims   If true, retains reduced dimensions with length 1.
  name   A name for the operation (optional).
  reduction_indices   The old (deprecated) name for axis.
  keep_dims   Deprecated alias for keepdims.

 Returns   The reduced tensor.
 Numpy Compatibility Equivalent to np.mean Please note that np.mean has a dtype parameter that could be used to specify the output type. By default this is dtype=float64. On the other hand, tf.reduce_mean has an aggressive type inference from input_tensor, for example:
x = tf.constant([1, 0, 1, 0])
tf.reduce_mean(x)
<tf.Tensor: shape=(), dtype=int32, numpy=0>
y = tf.constant([1., 0., 1., 0.])
tf.reduce_mean(y)
<tf.Tensor: shape=(), dtype=float32, numpy=0.5>


tf.compat.v1.reduce_min Computes the minimum of elements across dimensions of a tensor. (deprecated arguments)  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.math.reduce_min
tf.compat.v1.reduce_min(
    input_tensor, axis=None, keepdims=None, name=None, reduction_indices=None,
    keep_dims=None
)
 Warning: SOME ARGUMENTS ARE DEPRECATED: (keep_dims). They will be removed in a future version. Instructions for updating: keep_dims is deprecated, use keepdims instead Reduces input_tensor along the dimensions given in axis. Unless keepdims is true, the rank of the tensor is reduced by 1 for each of the entries in axis, which must be unique. If keepdims is true, the reduced dimensions are retained with length 1. If axis is None, all dimensions are reduced, and a tensor with a single element is returned.

 Args
  input_tensor   The tensor to reduce. Should have real numeric type.
  axis   The dimensions to reduce. If None (the default), reduces all dimensions. Must be in the range [-rank(input_tensor), rank(input_tensor)).
  keepdims   If true, retains reduced dimensions with length 1.
  name   A name for the operation (optional).
  reduction_indices   The old (deprecated) name for axis.
  keep_dims   Deprecated alias for keepdims.

 Returns   The reduced tensor.
 Numpy Compatibility Equivalent to np.min


tf.compat.v1.reduce_prod Computes the product of elements across dimensions of a tensor. (deprecated arguments)  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.math.reduce_prod
tf.compat.v1.reduce_prod(
    input_tensor, axis=None, keepdims=None, name=None, reduction_indices=None,
    keep_dims=None
)
 Warning: SOME ARGUMENTS ARE DEPRECATED: (keep_dims). They will be removed in a future version. Instructions for updating: keep_dims is deprecated, use keepdims instead Reduces input_tensor along the dimensions given in axis. Unless keepdims is true, the rank of the tensor is reduced by 1 for each of the entries in axis, which must be unique. If keepdims is true, the reduced dimensions are retained with length 1. If axis is None, all dimensions are reduced, and a tensor with a single element is returned.

 Args
  input_tensor   The tensor to reduce. Should have numeric type.
  axis   The dimensions to reduce. If None (the default), reduces all dimensions. Must be in the range [-rank(input_tensor), rank(input_tensor)).
  keepdims   If true, retains reduced dimensions with length 1.
  name   A name for the operation (optional).
  reduction_indices   The old (deprecated) name for axis.
  keep_dims   Deprecated alias for keepdims.

 Returns   The reduced tensor.
 Numpy Compatibility Equivalent to np.prod


tf.compat.v1.reduce_sum Computes the sum of elements across dimensions of a tensor. (deprecated arguments)  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.math.reduce_sum
tf.compat.v1.reduce_sum(
    input_tensor, axis=None, keepdims=None, name=None, reduction_indices=None,
    keep_dims=None
)
 Warning: SOME ARGUMENTS ARE DEPRECATED: (keep_dims). They will be removed in a future version. Instructions for updating: keep_dims is deprecated, use keepdims instead Reduces input_tensor along the dimensions given in axis. Unless keepdims is true, the rank of the tensor is reduced by 1 for each of the entries in axis, which must be unique. If keepdims is true, the reduced dimensions are retained with length 1. If axis is None, all dimensions are reduced, and a tensor with a single element is returned. For example: x = tf.constant([[1, 1, 1], [1, 1, 1]])
tf.reduce_sum(x)  # 6
tf.reduce_sum(x, 0)  # [2, 2, 2]
tf.reduce_sum(x, 1)  # [3, 3]
tf.reduce_sum(x, 1, keepdims=True)  # [[3], [3]]
tf.reduce_sum(x, [0, 1])  # 6

 Args
  input_tensor   The tensor to reduce. Should have numeric type.
  axis   The dimensions to reduce. If None (the default), reduces all dimensions. Must be in the range [-rank(input_tensor), rank(input_tensor)).
  keepdims   If true, retains reduced dimensions with length 1.
  name   A name for the operation (optional).
  reduction_indices   The old (deprecated) name for axis.
  keep_dims   Deprecated alias for keepdims.

 Returns   The reduced tensor, of the same dtype as the input_tensor.
 Numpy Compatibility Equivalent to np.sum apart the fact that numpy upcast uint8 and int32 to int64 while tensorflow returns the same dtype as the input.


tf.compat.v1.report_uninitialized_variables Adds ops to list the names of uninitialized variables.
tf.compat.v1.report_uninitialized_variables(
    var_list=None, name='report_uninitialized_variables'
)
 When run, it returns a 1-D tensor containing the names of uninitialized variables if there are any, or an empty array if there are none.

 Args
  var_list   List of Variable objects to check. Defaults to the value of global_variables() + local_variables()
  name   Optional name of the Operation.

 Returns   A 1-D tensor containing names of the uninitialized variables, or an empty 1-D tensor if there are no variables or no uninitialized variables.

Note: The output of this function should be used. If it is not, a warning will be logged or an error may be raised. To mark the output as used, call its .mark_used() method.


tf.compat.v1.reset_default_graph Clears the default graph stack and resets the global default graph.
tf.compat.v1.reset_default_graph()

Note: The default graph is a property of the current thread. This function applies only to the current thread. Calling this function while a tf.compat.v1.Session or tf.compat.v1.InteractiveSession is active will result in undefined behavior. Using any previously created tf.Operation or tf.Tensor objects after calling this function will result in undefined behavior. Raises: AssertionError: If this function is called within a nested graph.


Module: tf.compat.v1.resource_loader Resource management library. Functions get_data_files_path(...): Get a direct path to the data files colocated with the script. get_path_to_datafile(...): Get the path to the specified file in the data dependencies. get_root_dir_with_all_resources(...): Get a root directory containing all the data attributes in the build rule. load_resource(...): Load the resource at given path, where path is relative to tensorflow/. readahead_file_path(...): Readahead files not implemented; simply returns given path.


tf.compat.v1.resource_loader.get_data_files_path Get a direct path to the data files colocated with the script.
tf.compat.v1.resource_loader.get_data_files_path()

 Returns   The directory where files specified in data attribute of py_test and py_binary are stored.


tf.compat.v1.resource_loader.get_path_to_datafile Get the path to the specified file in the data dependencies.
tf.compat.v1.resource_loader.get_path_to_datafile(
    path
)
 The path is relative to tensorflow/

 Args
  path   a string resource path relative to tensorflow/

 Returns   The path to the specified file present in the data attribute of py_test or py_binary.

 Raises
  IOError   If the path is not found, or the resource can't be opened.


tf.compat.v1.resource_loader.get_root_dir_with_all_resources Get a root directory containing all the data attributes in the build rule.
tf.compat.v1.resource_loader.get_root_dir_with_all_resources()

 Returns   The path to the specified file present in the data attribute of py_test or py_binary. Falls back to returning the same as get_data_files_path if it fails to detect a bazel runfiles directory.


tf.compat.v1.resource_loader.load_resource Load the resource at given path, where path is relative to tensorflow/.
tf.compat.v1.resource_loader.load_resource(
    path
)

 Args
  path   a string resource path relative to tensorflow/.

 Returns   The contents of that resource.

 Raises
  IOError   If the path is not found, or the resource can't be opened.


tf.compat.v1.resource_loader.readahead_file_path Readahead files not implemented; simply returns given path.
tf.compat.v1.resource_loader.readahead_file_path(
    path, readahead='128M'
)


tf.compat.v1.resource_variables_enabled Returns True if resource variables are enabled.
tf.compat.v1.resource_variables_enabled()
 Resource variables are improved versions of TensorFlow variables with a well-defined memory model. Accessing a resource variable reads its value, and all ops which access a specific read value of the variable are guaranteed to see the same value for that tensor. Writes which happen after a read (by having a control or data dependency on the read) are guaranteed not to affect the value of the read tensor, and similarly writes which happen before a read are guaranteed to affect the value. No guarantees are made about unordered read/write pairs. Calling tf.enable_resource_variables() lets you opt-in to this TensorFlow 2.0 feature.


tf.compat.v1.reverse_sequence Reverses variable length slices. (deprecated arguments) (deprecated arguments)
tf.compat.v1.reverse_sequence(
    input, seq_lengths, seq_axis=None, batch_axis=None, name=None, seq_dim=None,
    batch_dim=None
)
 Warning: SOME ARGUMENTS ARE DEPRECATED: (seq_dim). They will be removed in a future version. Instructions for updating: seq_dim is deprecated, use seq_axis insteadWarning: SOME ARGUMENTS ARE DEPRECATED: (batch_dim). They will be removed in a future version. Instructions for updating: batch_dim is deprecated, use batch_axis instead This op first slices input along the dimension batch_axis, and for each slice i, reverses the first seq_lengths[i] elements along the dimension seq_axis. The elements of seq_lengths must obey seq_lengths[i] <= input.dims[seq_axis], and seq_lengths must be a vector of length input.dims[batch_axis]. The output slice i along dimension batch_axis is then given by input slice i, with the first seq_lengths[i] slices along dimension seq_axis reversed. Example usage:
seq_lengths = [7, 2, 3, 5]
input = [[1, 2, 3, 4, 5, 0, 0, 0], [1, 2, 0, 0, 0, 0, 0, 0],
         [1, 2, 3, 4, 0, 0, 0, 0], [1, 2, 3, 4, 5, 6, 7, 8]]
output = tf.reverse_sequence(input, seq_lengths, seq_axis=1, batch_axis=0)
output
<tf.Tensor: shape=(4, 8), dtype=int32, numpy=
array([[0, 0, 5, 4, 3, 2, 1, 0],
       [2, 1, 0, 0, 0, 0, 0, 0],
       [3, 2, 1, 4, 0, 0, 0, 0],
       [5, 4, 3, 2, 1, 6, 7, 8]], dtype=int32)>

 Args
  input   A Tensor. The input to reverse.
  seq_lengths   A Tensor. Must be one of the following types: int32, int64. 1-D with length input.dims(batch_axis) and max(seq_lengths) <= input.dims(seq_axis)
  seq_axis   An int. The dimension which is partially reversed.
  batch_axis   An optional int. Defaults to 0. The dimension along which reversal is performed.
  name   A name for the operation (optional).

 Returns   A Tensor. Has the same type as input.


tf.compat.v1.RunMetadata A ProtocolMessage

 Attributes
  cost_graph   CostGraphDef cost_graph
  function_graphs   repeated FunctionGraphs function_graphs
  partition_graphs   repeated GraphDef partition_graphs
  step_stats   StepStats step_stats    Child Classes class FunctionGraphs


tf.compat.v1.RunMetadata.FunctionGraphs A ProtocolMessage

 Attributes
  partition_graphs   repeated GraphDef partition_graphs
  post_optimization_graph   GraphDef post_optimization_graph
  pre_optimization_graph   GraphDef pre_optimization_graph


tf.compat.v1.RunOptions A ProtocolMessage

 Attributes
  debug_options   DebugOptions debug_options
  experimental   Experimental experimental
  inter_op_thread_pool   int32 inter_op_thread_pool
  output_partition_graphs   bool output_partition_graphs
  report_tensor_allocations_upon_oom   bool report_tensor_allocations_upon_oom
  timeout_in_ms   int64 timeout_in_ms
  trace_level   TraceLevel trace_level    Child Classes class Experimental

 Class Variables
  FULL_TRACE   3
  HARDWARE_TRACE   2
  NO_TRACE   0
  SOFTWARE_TRACE   1
  TraceLevel


tf.compat.v1.RunOptions.Experimental A ProtocolMessage

 Attributes
  collective_graph_key   int64 collective_graph_key
  run_handler_pool_options   RunHandlerPoolOptions run_handler_pool_options
  use_run_handler_pool   bool use_run_handler_pool    Child Classes class RunHandlerPoolOptions


tf.compat.v1.RunOptions.Experimental.RunHandlerPoolOptions A ProtocolMessage

 Attributes
  priority   int64 priority


Module: tf.compat.v1.saved_model Public API for tf.saved_model namespace. Modules builder module: SavedModel builder. constants module: Constants for SavedModel save and restore operations. experimental module: Public API for tf.saved_model.experimental namespace. loader module: Loader functionality for SavedModel with hermetic, language-neutral exports. main_op module: SavedModel main op. signature_constants module: Signature constants for SavedModel save and restore operations. signature_def_utils module: SignatureDef utility functions. tag_constants module: Common tags used for graphs in SavedModel. utils module: SavedModel utility functions. Classes class Asset: Represents a file asset to hermetically include in a SavedModel. class Builder: Builds the SavedModel protocol buffer and saves variables and assets. class SaveOptions: Options for saving to SavedModel. Functions build_signature_def(...): Utility function to build a SignatureDef protocol buffer. build_tensor_info(...): Utility function to build TensorInfo proto from a Tensor. (deprecated) classification_signature_def(...): Creates classification signature from given examples and predictions. contains_saved_model(...): Checks whether the provided export directory could contain a SavedModel. get_tensor_from_tensor_info(...): Returns the Tensor or CompositeTensor described by a TensorInfo proto. (deprecated) is_valid_signature(...): Determine whether a SignatureDef can be served by TensorFlow Serving. load(...): Loads the model from a SavedModel as specified by tags. (deprecated) load_v2(...): Load a SavedModel from export_dir. main_op_with_restore(...): Returns a main op to init variables, tables and restore the graph. (deprecated) maybe_saved_model_directory(...): Checks whether the provided export directory could contain a SavedModel. predict_signature_def(...): Creates prediction signature from given inputs and outputs. regression_signature_def(...): Creates regression signature from given examples and predictions. save(...): Exports the Trackable object obj to SavedModel format. simple_save(...): Convenience function to build a SavedModel suitable for serving. (deprecated)

 Other Members
  ASSETS_DIRECTORY   'assets'
  ASSETS_KEY   'saved_model_assets'
  CLASSIFY_INPUTS   'inputs'
  CLASSIFY_METHOD_NAME   'tensorflow/serving/classify'
  CLASSIFY_OUTPUT_CLASSES   'classes'
  CLASSIFY_OUTPUT_SCORES   'scores'
  DEBUG_DIRECTORY   'debug'
  DEBUG_INFO_FILENAME_PB   'saved_model_debug_info.pb'
  DEFAULT_SERVING_SIGNATURE_DEF_KEY   'serving_default'
  GPU   'gpu'
  LEGACY_INIT_OP_KEY   'legacy_init_op'
  MAIN_OP_KEY   'saved_model_main_op'
  PREDICT_INPUTS   'inputs'
  PREDICT_METHOD_NAME   'tensorflow/serving/predict'
  PREDICT_OUTPUTS   'outputs'
  REGRESS_INPUTS   'inputs'
  REGRESS_METHOD_NAME   'tensorflow/serving/regress'
  REGRESS_OUTPUTS   'outputs'
  SAVED_MODEL_FILENAME_PB   'saved_model.pb'
  SAVED_MODEL_FILENAME_PBTXT   'saved_model.pbtxt'
  SAVED_MODEL_SCHEMA_VERSION   1
  SERVING   'serve'
  TPU   'tpu'
  TRAINING   'train'
  VARIABLES_DIRECTORY   'variables'
  VARIABLES_FILENAME   'variables'


Module: tf.compat.v1.saved_model.builder SavedModel builder. Builds a SavedModel that can be saved to storage, is language neutral, and enables systems to produce, consume, or transform TensorFlow Models. Classes class SavedModelBuilder: Builds the SavedModel protocol buffer and saves variables and assets.


tf.compat.v1.saved_model.build_signature_def Utility function to build a SignatureDef protocol buffer.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.saved_model.signature_def_utils.build_signature_def
tf.compat.v1.saved_model.build_signature_def(
    inputs=None, outputs=None, method_name=None
)

 Args
  inputs   Inputs of the SignatureDef defined as a proto map of string to tensor info.
  outputs   Outputs of the SignatureDef defined as a proto map of string to tensor info.
  method_name   Method name of the SignatureDef as a string.

 Returns   A SignatureDef protocol buffer constructed based on the supplied arguments.


tf.compat.v1.saved_model.build_tensor_info Utility function to build TensorInfo proto from a Tensor. (deprecated)  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.saved_model.utils.build_tensor_info
tf.compat.v1.saved_model.build_tensor_info(
    tensor
)
 Warning: THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: This function will only be available through the v1 compatibility library as tf.compat.v1.saved_model.utils.build_tensor_info or tf.compat.v1.saved_model.build_tensor_info.

 Args
  tensor   Tensor or SparseTensor whose name, dtype and shape are used to build the TensorInfo. For SparseTensors, the names of the three constituent Tensors are used.

 Returns   A TensorInfo protocol buffer constructed based on the supplied argument.

 Raises
  RuntimeError   If eager execution is enabled.


tf.compat.v1.saved_model.classification_signature_def Creates classification signature from given examples and predictions.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.saved_model.signature_def_utils.classification_signature_def
tf.compat.v1.saved_model.classification_signature_def(
    examples, classes, scores
)
 This function produces signatures intended for use with the TensorFlow Serving Classify API (tensorflow_serving/apis/prediction_service.proto), and so constrains the input and output types to those allowed by TensorFlow Serving.

 Args
  examples   A string Tensor, expected to accept serialized tf.Examples.
  classes   A string Tensor. Note that the ClassificationResponse message requires that class labels are strings, not integers or anything else.
  scores   a float Tensor.

 Returns   A classification-flavored signature_def.

 Raises
  ValueError   If examples is None.


Module: tf.compat.v1.saved_model.constants Constants for SavedModel save and restore operations.

 Other Members
  ASSETS_DIRECTORY   'assets'
  ASSETS_KEY   'saved_model_assets'
  DEBUG_DIRECTORY   'debug'
  DEBUG_INFO_FILENAME_PB   'saved_model_debug_info.pb'
  LEGACY_INIT_OP_KEY   'legacy_init_op'
  MAIN_OP_KEY   'saved_model_main_op'
  SAVED_MODEL_FILENAME_PB   'saved_model.pb'
  SAVED_MODEL_FILENAME_PBTXT   'saved_model.pbtxt'
  SAVED_MODEL_SCHEMA_VERSION   1
  VARIABLES_DIRECTORY   'variables'
  VARIABLES_FILENAME   'variables'


tf.compat.v1.saved_model.contains_saved_model Checks whether the provided export directory could contain a SavedModel.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.saved_model.loader.maybe_saved_model_directory, tf.compat.v1.saved_model.maybe_saved_model_directory
tf.compat.v1.saved_model.contains_saved_model(
    export_dir
)
 Note that the method does not load any data by itself. If the method returns false, the export directory definitely does not contain a SavedModel. If the method returns true, the export directory may contain a SavedModel but provides no guarantee that it can be loaded.

 Args
  export_dir   Absolute string path to possible export location. For example, '/my/foo/model'.

 Returns   True if the export directory contains SavedModel files, False otherwise.


Module: tf.compat.v1.saved_model.experimental Public API for tf.saved_model.experimental namespace. Classes class VariablePolicy: Enum defining options for variable handling when saving. Functions save(...): Exports the Trackable object obj to SavedModel format.


tf.compat.v1.saved_model.get_tensor_from_tensor_info Returns the Tensor or CompositeTensor described by a TensorInfo proto. (deprecated)  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.saved_model.utils.get_tensor_from_tensor_info
tf.compat.v1.saved_model.get_tensor_from_tensor_info(
    tensor_info, graph=None, import_scope=None
)
 Warning: THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: This function will only be available through the v1 compatibility library as tf.compat.v1.saved_model.utils.get_tensor_from_tensor_info or tf.compat.v1.saved_model.get_tensor_from_tensor_info.

 Args
  tensor_info   A TensorInfo proto describing a Tensor or SparseTensor or CompositeTensor.
  graph   The tf.Graph in which tensors are looked up. If None, the current default graph is used.
  import_scope   If not None, names in tensor_info are prefixed with this string before lookup.

 Returns   The Tensor or SparseTensor or CompositeTensor in graph described by tensor_info.

 Raises
  KeyError   If tensor_info does not correspond to a tensor in graph.
  ValueError   If tensor_info is malformed.


tf.compat.v1.saved_model.is_valid_signature Determine whether a SignatureDef can be served by TensorFlow Serving.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.saved_model.signature_def_utils.is_valid_signature
tf.compat.v1.saved_model.is_valid_signature(
    signature_def
)


tf.compat.v1.saved_model.load Loads the model from a SavedModel as specified by tags. (deprecated)  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.saved_model.loader.load
tf.compat.v1.saved_model.load(
    sess, tags, export_dir, import_scope=None, **saver_kwargs
)
 Warning: THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: This function will only be available through the v1 compatibility library as tf.compat.v1.saved_model.loader.load or tf.compat.v1.saved_model.load. There will be a new function for importing SavedModels in Tensorflow 2.0.

 Args
  sess   The TensorFlow session to restore the variables.
  tags   Set of string tags to identify the required MetaGraphDef. These should correspond to the tags used when saving the variables using the SavedModel save() API.
  export_dir   Directory in which the SavedModel protocol buffer and variables to be loaded are located.
  import_scope   Optional string -- if specified, prepend this string followed by '/' to all loaded tensor names. This scope is applied to tensor instances loaded into the passed session, but it is not written through to the static MetaGraphDef protocol buffer that is returned.
  **saver_kwargs   Optional keyword arguments passed through to Saver.

 Returns   The MetaGraphDef protocol buffer loaded in the provided session. This can be used to further extract signature-defs, collection-defs, etc.

 Raises
  RuntimeError   MetaGraphDef associated with the tags cannot be found.


Module: tf.compat.v1.saved_model.loader Loader functionality for SavedModel with hermetic, language-neutral exports. Load and restore capability for a SavedModel, which may include multiple meta graph defs. Each SavedModel is associated with a single checkpoint. Each meta graph def is saved with one or more tags, which are used to identify the exact meta graph def to load. The load operation requires the session in which to restore the graph definition and variables, the tags used to identify the meta graph def to load and the location of the SavedModel. Upon a load, the subset of variables and assets supplied as part of the specific meta graph def, will be restored into the supplied session. The values of the variables though will correspond to the saved values from the first meta graph added to the SavedModel using add_meta_graph_and_variables(...) in builder.py. Typical usage: ...
builder = tf.compat.v1.saved_model.builder.SavedModelBuilder(export_dir)

with tf.compat.v1.Session(graph=tf.Graph()) as sess:
  ...
  builder.add_meta_graph_and_variables(sess,
                                       ["foo-tag"],
                                       signature_def_map=foo_signatures,
                                       assets_collection=foo_assets)
...

with tf.compat.v1.Session(graph=tf.Graph()) as sess:
  ...
  builder.add_meta_graph(["bar-tag", "baz-tag"],
                         assets_collection=bar_baz_assets)
...

builder.save()

...
with tf.compat.v1.Session(graph=tf.Graph()) as sess:
  tf.compat.v1.saved_model.loader.load(sess, ["foo-tag"], export_dir)
  ...

 Functions load(...): Loads the model from a SavedModel as specified by tags. (deprecated) maybe_saved_model_directory(...): Checks whether the provided export directory could contain a SavedModel.


Module: tf.compat.v1.saved_model.main_op SavedModel main op. Builds a main op that defines the sequence of ops to be run as part of the SavedModel load/restore operations. Functions main_op(...): Returns a main op to init variables and tables. (deprecated) main_op_with_restore(...): Returns a main op to init variables, tables and restore the graph. (deprecated)


tf.compat.v1.saved_model.main_op.main_op Returns a main op to init variables and tables. (deprecated)
tf.compat.v1.saved_model.main_op.main_op()
 Warning: THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: This function will only be available through the v1 compatibility library as tf.compat.v1.saved_model.main_op.main_op. Returns the main op including the group of ops that initializes all variables, initializes local variables and initialize all tables.

 Returns   The set of ops to be run as part of the main op upon the load operation.


tf.compat.v1.saved_model.main_op_with_restore Returns a main op to init variables, tables and restore the graph. (deprecated)  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.saved_model.main_op.main_op_with_restore
tf.compat.v1.saved_model.main_op_with_restore(
    restore_op_name
)
 Warning: THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: This function will only be available through the v1 compatibility library as tf.compat.v1.saved_model.main_op_with_restore or tf.compat.v1.saved_model.main_op.main_op_with_restore. Returns the main op including the group of ops that initializes all variables, initialize local variables, initialize all tables and the restore op name.

 Args
  restore_op_name   Name of the op to use to restore the graph.

 Returns   The set of ops to be run as part of the main op upon the load operation.


tf.compat.v1.saved_model.predict_signature_def Creates prediction signature from given inputs and outputs.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.saved_model.signature_def_utils.predict_signature_def
tf.compat.v1.saved_model.predict_signature_def(
    inputs, outputs
)
 This function produces signatures intended for use with the TensorFlow Serving Predict API (tensorflow_serving/apis/prediction_service.proto). This API imposes no constraints on the input and output types.

 Args
  inputs   dict of string to Tensor.
  outputs   dict of string to Tensor.

 Returns   A prediction-flavored signature_def.

 Raises
  ValueError   If inputs or outputs is None.


tf.compat.v1.saved_model.regression_signature_def Creates regression signature from given examples and predictions.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.saved_model.signature_def_utils.regression_signature_def
tf.compat.v1.saved_model.regression_signature_def(
    examples, predictions
)
 This function produces signatures intended for use with the TensorFlow Serving Regress API (tensorflow_serving/apis/prediction_service.proto), and so constrains the input and output types to those allowed by TensorFlow Serving.

 Args
  examples   A string Tensor, expected to accept serialized tf.Examples.
  predictions   A float Tensor.

 Returns   A regression-flavored signature_def.

 Raises
  ValueError   If examples is None.


Module: tf.compat.v1.saved_model.signature_constants Signature constants for SavedModel save and restore operations.

 Other Members
  CLASSIFY_INPUTS   'inputs'
  CLASSIFY_METHOD_NAME   'tensorflow/serving/classify'
  CLASSIFY_OUTPUT_CLASSES   'classes'
  CLASSIFY_OUTPUT_SCORES   'scores'
  DEFAULT_SERVING_SIGNATURE_DEF_KEY   'serving_default'
  PREDICT_INPUTS   'inputs'
  PREDICT_METHOD_NAME   'tensorflow/serving/predict'
  PREDICT_OUTPUTS   'outputs'
  REGRESS_INPUTS   'inputs'
  REGRESS_METHOD_NAME   'tensorflow/serving/regress'
  REGRESS_OUTPUTS   'outputs'


Module: tf.compat.v1.saved_model.signature_def_utils SignatureDef utility functions. Utility functions for building and inspecting SignatureDef protos. Classes class MethodNameUpdater: Updates the method name(s) of the SavedModel stored in the given path. Functions build_signature_def(...): Utility function to build a SignatureDef protocol buffer. classification_signature_def(...): Creates classification signature from given examples and predictions. is_valid_signature(...): Determine whether a SignatureDef can be served by TensorFlow Serving. predict_signature_def(...): Creates prediction signature from given inputs and outputs. regression_signature_def(...): Creates regression signature from given examples and predictions.


tf.compat.v1.saved_model.signature_def_utils.MethodNameUpdater Updates the method name(s) of the SavedModel stored in the given path.
tf.compat.v1.saved_model.signature_def_utils.MethodNameUpdater(
    export_dir
)
 The MethodNameUpdater class provides the functionality to update the method name field in the signature_defs of the given SavedModel. For example, it can be used to replace the predict method_name to regress. Typical usages of the MethodNameUpdater ...
updater = tf.compat.v1.saved_model.signature_def_utils.MethodNameUpdater(
    export_dir)
# Update all signature_defs with key "foo" in all meta graph defs.
updater.replace_method_name(signature_key="foo", method_name="regress")
# Update a single signature_def with key "bar" in the meta graph def with
# tags ["serve"]
updater.replace_method_name(signature_key="bar", method_name="classify",
                            tags="serve")
updater.save(new_export_dir)

Note: This function will only be available through the v1 compatibility library as tf.compat.v1.saved_model.builder.MethodNameUpdater.

 Args
  export_dir   Directory containing the SavedModel files.

 Raises
  IOError   If the saved model file does not exist, or cannot be successfully parsed.    Methods replace_method_name View source
replace_method_name(
    signature_key, method_name, tags=None
)
 Replaces the method_name in the specified signature_def. This will match and replace multiple sig defs iff tags is None (i.e when multiple MetaGraphs have a signature_def with the same key). If tags is not None, this will only replace a single signature_def in the MetaGraph with matching tags.

 Args
  signature_key   Key of the signature_def to be updated.
  method_name   new method_name to replace the existing one.
  tags   A tag or sequence of tags identifying the MetaGraph to update. If None, all meta graphs will be updated.

 Raises
  ValueError   if signature_key or method_name are not defined or if no metagraphs were found with the associated tags or if no meta graph has a signature_def that matches signature_key.    save View source
save(
    new_export_dir=None
)
 Saves the updated SavedModel.

 Args
  new_export_dir   Path where the updated SavedModel will be saved. If None, the input SavedModel will be overriden with the updates.

 Raises
  errors.OpError   If there are errors during the file save operation.


tf.compat.v1.saved_model.simple_save Convenience function to build a SavedModel suitable for serving. (deprecated)
tf.compat.v1.saved_model.simple_save(
    session, export_dir, inputs, outputs, legacy_init_op=None
)
 Warning: THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: This function will only be available through the v1 compatibility library as tf.compat.v1.saved_model.simple_save. In many common cases, saving models for serving will be as simple as: simple_save(session,
            export_dir,
            inputs={"x": x, "y": y},
            outputs={"z": z})
 Although in many cases it's not necessary to understand all of the many ways to configure a SavedModel, this method has a few practical implications:  It will be treated as a graph for inference / serving (i.e. uses the tag saved_model.SERVING) The SavedModel will load in TensorFlow Serving and supports the Predict API. To use the Classify, Regress, or MultiInference APIs, please use either tf.Estimator or the lower level SavedModel APIs. Some TensorFlow ops depend on information on disk or other information called "assets". These are generally handled automatically by adding the assets to the GraphKeys.ASSET_FILEPATHS collection. Only assets in that collection are exported; if you need more custom behavior, you'll need to use the SavedModelBuilder.  More information about SavedModel and signatures can be found here: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/saved_model/README.md

 Args
  session   The TensorFlow session from which to save the meta graph and variables.
  export_dir   The path to which the SavedModel will be stored.
  inputs   dict mapping string input names to tensors. These are added to the SignatureDef as the inputs.
  outputs   dict mapping string output names to tensors. These are added to the SignatureDef as the outputs.
  legacy_init_op   Legacy support for op or group of ops to execute after the restore op upon a load.


Module: tf.compat.v1.saved_model.tag_constants Common tags used for graphs in SavedModel.

 Other Members
  GPU   'gpu'
  SERVING   'serve'
  TPU   'tpu'
  TRAINING   'train'


Module: tf.compat.v1.saved_model.utils SavedModel utility functions. Utility functions to assist with setup and construction of the SavedModel proto. Functions build_tensor_info(...): Utility function to build TensorInfo proto from a Tensor. (deprecated) get_tensor_from_tensor_info(...): Returns the Tensor or CompositeTensor described by a TensorInfo proto. (deprecated)


tf.compat.v1.scalar_mul Multiplies a scalar times a Tensor or IndexedSlices object.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.math.scalar_mul
tf.compat.v1.scalar_mul(
    scalar, x, name=None
)
 Intended for use in gradient code which might deal with IndexedSlices objects, which are easy to multiply by a scalar but more expensive to multiply with arbitrary tensors.

 Args
  scalar   A 0-D scalar Tensor. Must have known shape.
  x   A Tensor or IndexedSlices to be scaled.
  name   A name for the operation (optional).

 Returns   scalar * x of the same type (Tensor or IndexedSlices) as x.

 Raises
  ValueError   if scalar is not a 0-D scalar.


tf.compat.v1.scan scan on the list of tensors unpacked from elems on dimension 0.
tf.compat.v1.scan(
    fn, elems, initializer=None, parallel_iterations=10, back_prop=True,
    swap_memory=False, infer_shape=True, reverse=False, name=None
)
 See also tf.map_fn. The simplest version of scan repeatedly applies the callable fn to a sequence of elements from first to last. The elements are made of the tensors unpacked from elems on dimension 0. The callable fn takes two tensors as arguments. The first argument is the accumulated value computed from the preceding invocation of fn, and the second is the value at the current position of elems. If initializer is None, elems must contain at least one element, and its first element is used as the initializer. Suppose that elems is unpacked into values, a list of tensors. The shape of the result tensor is [len(values)] + fn(initializer, values[0]).shape. If reverse=True, it's fn(initializer, values[-1]).shape. This method also allows multi-arity elems and accumulator. If elems is a (possibly nested) list or tuple of tensors, then each of these tensors must have a matching first (unpack) dimension. The second argument of fn must match the structure of elems. If no initializer is provided, the output structure and dtypes of fn are assumed to be the same as its input; and in this case, the first argument of fn must match the structure of elems. If an initializer is provided, then the output of fn must have the same structure as initializer; and the first argument of fn must match this structure. For example, if elems is (t1, [t2, t3]) and initializer is [i1, i2] then an appropriate signature for fn in python2 is: fn = lambda (acc_p1, acc_p2), (t1, [t2, t3]): and fn must return a list, [acc_n1, acc_n2]. An alternative correct signature for fn, and the one that works in python3, is: fn = lambda a, t:, where a and t correspond to the input tuples.

 Args
  fn   The callable to be performed. It accepts two arguments. The first will have the same structure as initializer if one is provided, otherwise it will have the same structure as elems. The second will have the same (possibly nested) structure as elems. Its output must have the same structure as initializer if one is provided, otherwise it must have the same structure as elems.
  elems   A tensor or (possibly nested) sequence of tensors, each of which will be unpacked along their first dimension. The nested sequence of the resulting slices will be the first argument to fn.
  initializer   (optional) A tensor or (possibly nested) sequence of tensors, initial value for the accumulator, and the expected output type of fn.
  parallel_iterations   (optional) The number of iterations allowed to run in parallel.
  back_prop   (optional) True enables support for back propagation.
  swap_memory   (optional) True enables GPU-CPU memory swapping.
  infer_shape   (optional) False disables tests for consistent output shapes.
  reverse   (optional) True scans the tensor last to first (instead of first to last).
  name   (optional) Name prefix for the returned tensors.

 Returns   A tensor or (possibly nested) sequence of tensors. Each tensor packs the results of applying fn to tensors unpacked from elems along the first dimension, and the previous accumulator value(s), from first to last (or last to first, if reverse=True).

 Raises
  TypeError   if fn is not callable or the structure of the output of fn and initializer do not match.
  ValueError   if the lengths of the output of fn and initializer do not match.    Examples: elems = np.array([1, 2, 3, 4, 5, 6])
sum = scan(lambda a, x: a + x, elems)
# sum == [1, 3, 6, 10, 15, 21]
sum = scan(lambda a, x: a + x, elems, reverse=True)
# sum == [21, 20, 18, 15, 11, 6]

elems = np.array([1, 2, 3, 4, 5, 6])
initializer = np.array(0)
sum_one = scan(
    lambda a, x: x[0] - x[1] + a, (elems + 1, elems), initializer)
# sum_one == [1, 2, 3, 4, 5, 6]

elems = np.array([1, 0, 0, 0, 0, 0])
initializer = (np.array(0), np.array(1))
fibonaccis = scan(lambda a, _: (a[1], a[0] + a[1]), elems, initializer)
# fibonaccis == ([1, 1, 2, 3, 5, 8], [1, 2, 3, 5, 8, 13])


tf.compat.v1.scatter_add Adds sparse updates to the variable referenced by resource.
tf.compat.v1.scatter_add(
    ref, indices, updates, use_locking=False, name=None
)
 This operation computes # Scalar indices
ref[indices, ...] += updates[...]

# Vector indices (for each i)
ref[indices[i], ...] += updates[i, ...]

# High rank indices (for each i, ..., j)
ref[indices[i, ..., j], ...] += updates[i, ..., j, ...]
 This operation outputs ref after the update is done. This makes it easier to chain operations that need to use the updated value. Duplicate entries are handled correctly: if multiple indices reference the same location, their contributions add. Requires updates.shape = indices.shape + ref.shape[1:].

 Args
  ref   A Variable.
  indices   A Tensor. Must be one of the following types: int32, int64. A tensor of indices into the first dimension of ref.
  updates   A Tensor. Must have the same type as ref. A tensor of updated values to store in ref.
  use_locking   An optional bool. Defaults to False. If True, the assignment will be protected by a lock; otherwise the behavior is undefined, but may exhibit less contention.
  name   A name for the operation (optional).

 Returns   Same as ref. Returned as a convenience for operations that want to use the updated values after the update is done.


tf.compat.v1.scatter_div Divides a variable reference by sparse updates.
tf.compat.v1.scatter_div(
    ref, indices, updates, use_locking=False, name=None
)
 This operation computes # Scalar indices
ref[indices, ...] /= updates[...]

# Vector indices (for each i)
ref[indices[i], ...] /= updates[i, ...]

# High rank indices (for each i, ..., j)
ref[indices[i, ..., j], ...] /= updates[i, ..., j, ...]
 This operation outputs ref after the update is done. This makes it easier to chain operations that need to use the reset value. Duplicate entries are handled correctly: if multiple indices reference the same location, their contributions divide. Requires updates.shape = indices.shape + ref.shape[1:] or updates.shape = [].

 Args
  ref   A mutable Tensor. Must be one of the following types: float32, float64, int32, uint8, int16, int8, complex64, int64, qint8, quint8, qint32, bfloat16, uint16, complex128, half, uint32, uint64. Should be from a Variable node.
  indices   A Tensor. Must be one of the following types: int32, int64. A tensor of indices into the first dimension of ref.
  updates   A Tensor. Must have the same type as ref. A tensor of values that ref is divided by.
  use_locking   An optional bool. Defaults to False. If True, the operation will be protected by a lock; otherwise the behavior is undefined, but may exhibit less contention.
  name   A name for the operation (optional).

 Returns   A mutable Tensor. Has the same type as ref.


tf.compat.v1.scatter_max Reduces sparse updates into a variable reference using the max operation.
tf.compat.v1.scatter_max(
    ref, indices, updates, use_locking=False, name=None
)
 This operation computes # Scalar indices
ref[indices, ...] = max(ref[indices, ...], updates[...])

# Vector indices (for each i)
ref[indices[i], ...] = max(ref[indices[i], ...], updates[i, ...])

# High rank indices (for each i, ..., j)
ref[indices[i, ..., j], ...] = max(ref[indices[i, ..., j], ...],
updates[i, ..., j, ...])
 This operation outputs ref after the update is done. This makes it easier to chain operations that need to use the reset value. Duplicate entries are handled correctly: if multiple indices reference the same location, their contributions combine. Requires updates.shape = indices.shape + ref.shape[1:] or updates.shape = [].

 Args
  ref   A mutable Tensor. Must be one of the following types: half, bfloat16, float32, float64, int32, int64. Should be from a Variable node.
  indices   A Tensor. Must be one of the following types: int32, int64. A tensor of indices into the first dimension of ref.
  updates   A Tensor. Must have the same type as ref. A tensor of updated values to reduce into ref.
  use_locking   An optional bool. Defaults to False. If True, the update will be protected by a lock; otherwise the behavior is undefined, but may exhibit less contention.
  name   A name for the operation (optional).

 Returns   A mutable Tensor. Has the same type as ref.


tf.compat.v1.scatter_min Reduces sparse updates into a variable reference using the min operation.
tf.compat.v1.scatter_min(
    ref, indices, updates, use_locking=False, name=None
)
 This operation computes # Scalar indices
ref[indices, ...] = min(ref[indices, ...], updates[...])

# Vector indices (for each i)
ref[indices[i], ...] = min(ref[indices[i], ...], updates[i, ...])

# High rank indices (for each i, ..., j)
ref[indices[i, ..., j], ...] = min(ref[indices[i, ..., j], ...],
updates[i, ..., j, ...])
 This operation outputs ref after the update is done. This makes it easier to chain operations that need to use the reset value. Duplicate entries are handled correctly: if multiple indices reference the same location, their contributions combine. Requires updates.shape = indices.shape + ref.shape[1:] or updates.shape = [].

 Args
  ref   A mutable Tensor. Must be one of the following types: half, bfloat16, float32, float64, int32, int64. Should be from a Variable node.
  indices   A Tensor. Must be one of the following types: int32, int64. A tensor of indices into the first dimension of ref.
  updates   A Tensor. Must have the same type as ref. A tensor of updated values to reduce into ref.
  use_locking   An optional bool. Defaults to False. If True, the update will be protected by a lock; otherwise the behavior is undefined, but may exhibit less contention.
  name   A name for the operation (optional).

 Returns   A mutable Tensor. Has the same type as ref.


tf.compat.v1.scatter_mul Multiplies sparse updates into a variable reference.
tf.compat.v1.scatter_mul(
    ref, indices, updates, use_locking=False, name=None
)
 This operation computes # Scalar indices
ref[indices, ...] *= updates[...]

# Vector indices (for each i)
ref[indices[i], ...] *= updates[i, ...]

# High rank indices (for each i, ..., j)
ref[indices[i, ..., j], ...] *= updates[i, ..., j, ...]
 This operation outputs ref after the update is done. This makes it easier to chain operations that need to use the reset value. Duplicate entries are handled correctly: if multiple indices reference the same location, their contributions multiply. Requires updates.shape = indices.shape + ref.shape[1:] or updates.shape = [].

 Args
  ref   A mutable Tensor. Must be one of the following types: float32, float64, int32, uint8, int16, int8, complex64, int64, qint8, quint8, qint32, bfloat16, uint16, complex128, half, uint32, uint64. Should be from a Variable node.
  indices   A Tensor. Must be one of the following types: int32, int64. A tensor of indices into the first dimension of ref.
  updates   A Tensor. Must have the same type as ref. A tensor of updated values to multiply to ref.
  use_locking   An optional bool. Defaults to False. If True, the operation will be protected by a lock; otherwise the behavior is undefined, but may exhibit less contention.
  name   A name for the operation (optional).

 Returns   A mutable Tensor. Has the same type as ref.


tf.compat.v1.scatter_nd_add Applies sparse addition to individual values or slices in a Variable.
tf.compat.v1.scatter_nd_add(
    ref, indices, updates, use_locking=False, name=None
)
 ref is a Tensor with rank P and indices is a Tensor of rank Q. indices must be integer tensor, containing indices into ref. It must be shape [d_0, ..., d_{Q-2}, K] where 0 < K <= P. The innermost dimension of indices (with length K) corresponds to indices into elements (if K = P) or slices (if K < P) along the Kth dimension of ref. updates is Tensor of rank Q-1+P-K with shape: [d_0, ..., d_{Q-2}, ref.shape[K], ..., ref.shape[P-1]]
 For example, say we want to add 4 scattered elements to a rank-1 tensor to 8 elements. In Python, that addition would look like this: ref = tf.Variable([1, 2, 3, 4, 5, 6, 7, 8])
indices = tf.constant([[4], [3], [1], [7]])
updates = tf.constant([9, 10, 11, 12])
add = tf.compat.v1.scatter_nd_add(ref, indices, updates)
with tf.compat.v1.Session() as sess:
  print sess.run(add)
 The resulting update to ref would look like this: [1, 13, 3, 14, 14, 6, 7, 20]
 See tf.scatter_nd for more details about how to make updates to slices.

 Args
  ref   A mutable Tensor. Must be one of the following types: float32, float64, int32, uint8, int16, int8, complex64, int64, qint8, quint8, qint32, bfloat16, uint16, complex128, half, uint32, uint64. A mutable Tensor. Should be from a Variable node.
  indices   A Tensor. Must be one of the following types: int32, int64. A tensor of indices into ref.
  updates   A Tensor. Must have the same type as ref. A tensor of updated values to add to ref.
  use_locking   An optional bool. Defaults to False. If True, the assignment will be protected by a lock; otherwise the behavior is undefined, but may exhibit less contention.
  name   A name for the operation (optional).

 Returns   A mutable Tensor. Has the same type as ref.


tf.compat.v1.scatter_nd_sub Applies sparse subtraction to individual values or slices in a Variable.
tf.compat.v1.scatter_nd_sub(
    ref, indices, updates, use_locking=False, name=None
)
 ref is a Tensor with rank P and indices is a Tensor of rank Q. indices must be integer tensor, containing indices into ref. It must be shape [d_0, ..., d_{Q-2}, K] where 0 < K <= P. The innermost dimension of indices (with length K) corresponds to indices into elements (if K = P) or slices (if K < P) along the Kth dimension of ref. updates is Tensor of rank Q-1+P-K with shape: [d_0, ..., d_{Q-2}, ref.shape[K], ..., ref.shape[P-1]]
 For example, say we want to subtract 4 scattered elements from a rank-1 tensor with 8 elements. In Python, that update would look like this: ref = tf.Variable([1, 2, 3, 4, 5, 6, 7, 8])
indices = tf.constant([[4], [3], [1] ,[7]])
updates = tf.constant([9, 10, 11, 12])
op = tf.compat.v1.scatter_nd_sub(ref, indices, updates)
with tf.compat.v1.Session() as sess:
  print sess.run(op)
 The resulting update to ref would look like this: [1, -9, 3, -6, -6, 6, 7, -4]
 See tf.scatter_nd for more details about how to make updates to slices.

 Args
  ref   A mutable Tensor. Must be one of the following types: float32, float64, int32, uint8, int16, int8, complex64, int64, qint8, quint8, qint32, bfloat16, uint16, complex128, half, uint32, uint64. A mutable Tensor. Should be from a Variable node.
  indices   A Tensor. Must be one of the following types: int32, int64. A tensor of indices into ref.
  updates   A Tensor. Must have the same type as ref. A tensor of updated values to add to ref.
  use_locking   An optional bool. Defaults to False. An optional bool. Defaults to True. If True, the assignment will be protected by a lock; otherwise the behavior is undefined, but may exhibit less contention.
  name   A name for the operation (optional).

 Returns   A mutable Tensor. Has the same type as ref.


tf.compat.v1.scatter_nd_update Applies sparse updates to individual values or slices in a Variable.
tf.compat.v1.scatter_nd_update(
    ref, indices, updates, use_locking=True, name=None
)
 ref is a Tensor with rank P and indices is a Tensor of rank Q. indices must be integer tensor, containing indices into ref. It must be shape [d_0, ..., d_{Q-2}, K] where 0 < K <= P. The innermost dimension of indices (with length K) corresponds to indices into elements (if K = P) or slices (if K < P) along the Kth dimension of ref. updates is Tensor of rank Q-1+P-K with shape: [d_0, ..., d_{Q-2}, ref.shape[K], ..., ref.shape[P-1]].
 For example, say we want to update 4 scattered elements to a rank-1 tensor to 8 elements. In Python, that update would look like this: ref = tf.Variable([1, 2, 3, 4, 5, 6, 7, 8])
indices = tf.constant([[4], [3], [1] ,[7]])
updates = tf.constant([9, 10, 11, 12])
update = tf.compat.v1.scatter_nd_update(ref, indices, updates)
with tf.compat.v1.Session() as sess:
  print sess.run(update)
 The resulting update to ref would look like this: [1, 11, 3, 10, 9, 6, 7, 12]
 See tf.scatter_nd for more details about how to make updates to slices.

 Args
  ref   A Variable.
  indices   A Tensor. Must be one of the following types: int32, int64. A tensor of indices into ref.
  updates   A Tensor. Must have the same type as ref. A Tensor. Must have the same type as ref. A tensor of updated values to add to ref.
  use_locking   An optional bool. Defaults to True. An optional bool. Defaults to True. If True, the assignment will be protected by a lock; otherwise the behavior is undefined, but may exhibit less contention.
  name   A name for the operation (optional).

 Returns   The value of the variable after the update.


tf.compat.v1.scatter_sub Subtracts sparse updates to a variable reference.
tf.compat.v1.scatter_sub(
    ref, indices, updates, use_locking=False, name=None
)
 # Scalar indices
ref[indices, ...] -= updates[...]

# Vector indices (for each i)
ref[indices[i], ...] -= updates[i, ...]

# High rank indices (for each i, ..., j)
ref[indices[i, ..., j], ...] -= updates[i, ..., j, ...]
 This operation outputs ref after the update is done. This makes it easier to chain operations that need to use the reset value. Duplicate entries are handled correctly: if multiple indices reference the same location, their (negated) contributions add. Requires updates.shape = indices.shape + ref.shape[1:] or updates.shape = [].

 Args
  ref   A mutable Tensor. Must be one of the following types: float32, float64, int32, uint8, int16, int8, complex64, int64, qint8, quint8, qint32, bfloat16, uint16, complex128, half, uint32, uint64. Should be from a Variable node.
  indices   A Tensor. Must be one of the following types: int32, int64. A tensor of indices into the first dimension of ref.
  updates   A Tensor. Must have the same type as ref. A tensor of updated values to subtract from ref.
  use_locking   An optional bool. Defaults to False. If True, the subtraction will be protected by a lock; otherwise the behavior is undefined, but may exhibit less contention.
  name   A name for the operation (optional).

 Returns   A mutable Tensor. Has the same type as ref.


tf.compat.v1.scatter_update Applies sparse updates to a variable reference.
tf.compat.v1.scatter_update(
    ref, indices, updates, use_locking=True, name=None
)
 This operation computes # Scalar indices
ref[indices, ...] = updates[...]

# Vector indices (for each i)
ref[indices[i], ...] = updates[i, ...]

# High rank indices (for each i, ..., j)
ref[indices[i, ..., j], ...] = updates[i, ..., j, ...]
 This operation outputs ref after the update is done. This makes it easier to chain operations that need to use the reset value. If values in ref is to be updated more than once, because there are duplicate entries in indices, the order at which the updates happen for each value is undefined. Requires updates.shape = indices.shape + ref.shape[1:].

 Args
  ref   A Variable.
  indices   A Tensor. Must be one of the following types: int32, int64. A tensor of indices into the first dimension of ref.
  updates   A Tensor. Must have the same type as ref. A tensor of updated values to store in ref.
  use_locking   An optional bool. Defaults to True. If True, the assignment will be protected by a lock; otherwise the behavior is undefined, but may exhibit less contention.
  name   A name for the operation (optional).

 Returns   Same as ref. Returned as a convenience for operations that want to use the updated values after the update is done.


tf.compat.v1.serialize_many_sparse Serialize N-minibatch SparseTensor into an [N, 3] Tensor.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.io.serialize_many_sparse
tf.compat.v1.serialize_many_sparse(
    sp_input, name=None, out_type=tf.dtypes.string
)
 The SparseTensor must have rank R greater than 1, and the first dimension is treated as the minibatch dimension. Elements of the SparseTensor must be sorted in increasing order of this first dimension. The serialized SparseTensor objects going into each row of the output Tensor will have rank R-1. The minibatch size N is extracted from sparse_shape[0].

 Args
  sp_input   The input rank R SparseTensor.
  name   A name prefix for the returned tensors (optional).
  out_type   The dtype to use for serialization.

 Returns   A matrix (2-D Tensor) with N rows and 3 columns. Each column represents serialized SparseTensor's indices, values, and shape (respectively).

 Raises
  TypeError   If sp_input is not a SparseTensor.


tf.compat.v1.serialize_sparse Serialize a SparseTensor into a 3-vector (1-D Tensor) object.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.io.serialize_sparse
tf.compat.v1.serialize_sparse(
    sp_input, name=None, out_type=tf.dtypes.string
)

 Args
  sp_input   The input SparseTensor.
  name   A name prefix for the returned tensors (optional).
  out_type   The dtype to use for serialization.

 Returns   A 3-vector (1-D Tensor), with each column representing the serialized SparseTensor's indices, values, and shape (respectively).

 Raises
  TypeError   If sp_input is not a SparseTensor.


tf.compat.v1.Session A class for running TensorFlow operations.
tf.compat.v1.Session(
    target='', graph=None, config=None
)
 A Session object encapsulates the environment in which Operation objects are executed, and Tensor objects are evaluated. For example: tf.compat.v1.disable_eager_execution() # need to disable eager in TF2.x
# Build a graph.
a = tf.constant(5.0)
b = tf.constant(6.0)
c = a * b

# Launch the graph in a session.
sess = tf.compat.v1.Session()

# Evaluate the tensor `c`.
print(sess.run(c)) # prints 30.0
 A session may own resources, such as tf.Variable, tf.queue.QueueBase, and tf.compat.v1.ReaderBase. It is important to release these resources when they are no longer required. To do this, either invoke the tf.Session.close method on the session, or use the session as a context manager. The following two examples are equivalent: # Using the `close()` method.
sess = tf.compat.v1.Session()
sess.run(...)
sess.close()

# Using the context manager.
with tf.compat.v1.Session() as sess:
  sess.run(...)
 The ConfigProto protocol buffer exposes various configuration options for a session. For example, to create a session that uses soft constraints for device placement, and log the resulting placement decisions, create a session as follows: # Launch the graph in a session that allows soft device placement and
# logs the placement decisions.
sess = tf.compat.v1.Session(config=tf.compat.v1.ConfigProto(
    allow_soft_placement=True,
    log_device_placement=True))

 Args
  target   (Optional.) The execution engine to connect to. Defaults to using an in-process engine. See Distributed TensorFlow for more examples.
  graph   (Optional.) The Graph to be launched (described above).
  config   (Optional.) A ConfigProto protocol buffer with configuration options for the session.

 Attributes
  graph   The graph that was launched in this session.
  graph_def   A serializable version of the underlying TensorFlow graph.
  sess_str   The TensorFlow process to which this session will connect.    Methods as_default View source
as_default()
 Returns a context manager that makes this object the default session. Use with the with keyword to specify that calls to tf.Operation.run or tf.Tensor.eval should be executed in this session. c = tf.constant(..)
sess = tf.compat.v1.Session()

with sess.as_default():
  assert tf.compat.v1.get_default_session() is sess
  print(c.eval())
 To get the current default session, use tf.compat.v1.get_default_session.
Note: The as_default context manager does not close the session when you exit the context, and you must close the session explicitly.

c = tf.constant(...)
sess = tf.compat.v1.Session()
with sess.as_default():
  print(c.eval())
# ...
with sess.as_default():
  print(c.eval())

sess.close()
 Alternatively, you can use with tf.compat.v1.Session(): to create a session that is automatically closed on exiting the context, including when an uncaught exception is raised.
Note: The default session is a property of the current thread. If you create a new thread, and wish to use the default session in that thread, you must explicitly add a with sess.as_default(): in that thread's function.

Note: Entering a with sess.as_default(): block does not affect the current default graph. If you are using multiple graphs, and sess.graph is different from the value of tf.compat.v1.get_default_graph, you must explicitly enter a with sess.graph.as_default(): block to make sess.graph the default graph.

 Returns   A context manager using this session as the default session.
 close View source
close()
 Closes this session. Calling this method frees all resources associated with the session.

 Raises
  tf.errors.OpError   Or one of its subclasses if an error occurs while closing the TensorFlow session.    list_devices View source
list_devices()
 Lists available devices in this session. devices = sess.list_devices()
for d in devices:
  print(d.name)
 Where: Each element in the list has the following properties
name: A string with the full name of the device. ex: /job:worker/replica:0/task:3/device:CPU:0

device_type: The type of the device (e.g. CPU, GPU, TPU.)
memory_limit: The maximum amount of memory available on the device. Note: depending on the device, it is possible the usable memory could be substantially less.

 Raises
  tf.errors.OpError   If it encounters an error (e.g. session is in an invalid state, or network errors occur).

 Returns   A list of devices in the session.
 make_callable View source
make_callable(
    fetches, feed_list=None, accept_options=False
)
 Returns a Python callable that runs a particular step. The returned callable will take len(feed_list) arguments whose types must be compatible feed values for the respective elements of feed_list. For example, if element i of feed_list is a tf.Tensor, the ith argument to the returned callable must be a numpy ndarray (or something convertible to an ndarray) with matching element type and shape. See tf.Session.run for details of the allowable feed key and value types. The returned callable will have the same return type as tf.Session.run(fetches, ...). For example, if fetches is a tf.Tensor, the callable will return a numpy ndarray; if fetches is a tf.Operation, it will return None.

 Args
  fetches   A value or list of values to fetch. See tf.Session.run for details of the allowable fetch types.
  feed_list   (Optional.) A list of feed_dict keys. See tf.Session.run for details of the allowable feed key types.
  accept_options   (Optional.) If True, the returned Callable will be able to accept tf.compat.v1.RunOptions and tf.compat.v1.RunMetadata as optional keyword arguments options and run_metadata, respectively, with the same syntax and semantics as tf.Session.run, which is useful for certain use cases (profiling and debugging) but will result in measurable slowdown of the Callable's performance. Default: False.

 Returns   A function that when called will execute the step defined by feed_list and fetches in this session.

 Raises
  TypeError   If fetches or feed_list cannot be interpreted as arguments to tf.Session.run.    partial_run View source
partial_run(
    handle, fetches, feed_dict=None
)
 Continues the execution with more feeds and fetches. This is EXPERIMENTAL and subject to change. To use partial execution, a user first calls partial_run_setup() and then a sequence of partial_run(). partial_run_setup specifies the list of feeds and fetches that will be used in the subsequent partial_run calls. The optional feed_dict argument allows the caller to override the value of tensors in the graph. See run() for more information. Below is a simple example: a = array_ops.placeholder(dtypes.float32, shape=[])
b = array_ops.placeholder(dtypes.float32, shape=[])
c = array_ops.placeholder(dtypes.float32, shape=[])
r1 = math_ops.add(a, b)
r2 = math_ops.multiply(r1, c)

h = sess.partial_run_setup([r1, r2], [a, b, c])
res = sess.partial_run(h, r1, feed_dict={a: 1, b: 2})
res = sess.partial_run(h, r2, feed_dict={c: res})

 Args
  handle   A handle for a sequence of partial runs.
  fetches   A single graph element, a list of graph elements, or a dictionary whose values are graph elements or lists of graph elements (see documentation for run).
  feed_dict   A dictionary that maps graph elements to values (described above).

 Returns   Either a single value if fetches is a single graph element, or a list of values if fetches is a list, or a dictionary with the same keys as fetches if that is a dictionary (see documentation for run).

 Raises
  tf.errors.OpError   Or one of its subclasses on error.    partial_run_setup View source
partial_run_setup(
    fetches, feeds=None
)
 Sets up a graph with feeds and fetches for partial run. This is EXPERIMENTAL and subject to change. Note that contrary to run, feeds only specifies the graph elements. The tensors will be supplied by the subsequent partial_run calls.

 Args
  fetches   A single graph element, or a list of graph elements.
  feeds   A single graph element, or a list of graph elements.

 Returns   A handle for partial run.

 Raises
  RuntimeError   If this Session is in an invalid state (e.g. has been closed).
  TypeError   If fetches or feed_dict keys are of an inappropriate type.
  tf.errors.OpError   Or one of its subclasses if a TensorFlow error happens.    reset View source
@staticmethod
reset(
    target, containers=None, config=None
)
 Resets resource containers on target, and close all connected sessions. A resource container is distributed across all workers in the same cluster as target. When a resource container on target is reset, resources associated with that container will be cleared. In particular, all Variables in the container will become undefined: they lose their values and shapes. NOTE: (i) reset() is currently only implemented for distributed sessions. (ii) Any sessions on the master named by target will be closed. If no resource containers are provided, all containers are reset.

 Args
  target   The execution engine to connect to.
  containers   A list of resource container name strings, or None if all of all the containers are to be reset.
  config   (Optional.) Protocol buffer with configuration options.

 Raises
  tf.errors.OpError   Or one of its subclasses if an error occurs while resetting containers.    run View source
run(
    fetches, feed_dict=None, options=None, run_metadata=None
)
 Runs operations and evaluates tensors in fetches. This method runs one "step" of TensorFlow computation, by running the necessary graph fragment to execute every Operation and evaluate every Tensor in fetches, substituting the values in feed_dict for the corresponding input values. The fetches argument may be a single graph element, or an arbitrarily nested list, tuple, namedtuple, dict, or OrderedDict containing graph elements at its leaves. A graph element can be one of the following types:  A tf.Operation. The corresponding fetched value will be None. A tf.Tensor. The corresponding fetched value will be a numpy ndarray containing the value of that tensor. A tf.sparse.SparseTensor. The corresponding fetched value will be a tf.compat.v1.SparseTensorValue containing the value of that sparse tensor. A get_tensor_handle op. The corresponding fetched value will be a numpy ndarray containing the handle of that tensor. A string which is the name of a tensor or operation in the graph.  The value returned by run() has the same shape as the fetches argument, where the leaves are replaced by the corresponding values returned by TensorFlow. Example: a = tf.constant([10, 20])
b = tf.constant([1.0, 2.0])
# 'fetches' can be a singleton
v = session.run(a)
# v is the numpy array [10, 20]
# 'fetches' can be a list.
v = session.run([a, b])
# v is a Python list with 2 numpy arrays: the 1-D array [10, 20] and the
# 1-D array [1.0, 2.0]
# 'fetches' can be arbitrary lists, tuples, namedtuple, dicts:
MyData = collections.namedtuple('MyData', ['a', 'b'])
v = session.run({'k1': MyData(a, b), 'k2': [b, a]})
# v is a dict with
# v['k1'] is a MyData namedtuple with 'a' (the numpy array [10, 20]) and
# 'b' (the numpy array [1.0, 2.0])
# v['k2'] is a list with the numpy array [1.0, 2.0] and the numpy array
# [10, 20].
 The optional feed_dict argument allows the caller to override the value of tensors in the graph. Each key in feed_dict can be one of the following types:  If the key is a tf.Tensor, the value may be a Python scalar, string, list, or numpy ndarray that can be converted to the same dtype as that tensor. Additionally, if the key is a tf.compat.v1.placeholder, the shape of the value will be checked for compatibility with the placeholder. If the key is a tf.sparse.SparseTensor, the value should be a tf.compat.v1.SparseTensorValue. If the key is a nested tuple of Tensors or SparseTensors, the value should be a nested tuple with the same structure that maps to their corresponding values as above.  Each value in feed_dict must be convertible to a numpy array of the dtype of the corresponding key. The optional options argument expects a [RunOptions] proto. The options allow controlling the behavior of this particular step (e.g. turning tracing on). The optional run_metadata argument expects a [RunMetadata] proto. When appropriate, the non-Tensor output of this step will be collected there. For example, when users turn on tracing in options, the profiled info will be collected into this argument and passed back.

 Args
  fetches   A single graph element, a list of graph elements, or a dictionary whose values are graph elements or lists of graph elements (described above).
  feed_dict   A dictionary that maps graph elements to values (described above).
  options   A [RunOptions] protocol buffer
  run_metadata   A [RunMetadata] protocol buffer

 Returns   Either a single value if fetches is a single graph element, or a list of values if fetches is a list, or a dictionary with the same keys as fetches if that is a dictionary (described above). Order in which fetches operations are evaluated inside the call is undefined.

 Raises
  RuntimeError   If this Session is in an invalid state (e.g. has been closed).
  TypeError   If fetches or feed_dict keys are of an inappropriate type.
  ValueError   If fetches or feed_dict keys are invalid or refer to a Tensor that doesn't exist.    __enter__ View source
__enter__()
 __exit__ View source
__exit__(
    exec_type, exec_value, exec_tb
)


tf.compat.v1.SessionLog A ProtocolMessage  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.summary.SessionLog

 Attributes
  checkpoint_path   string checkpoint_path
  msg   string msg
  status   SessionStatus status

 Class Variables
  CHECKPOINT   3
  START   1
  STATUS_UNSPECIFIED   0
  STOP   2
  SessionStatus


tf.compat.v1.setdiff1d Computes the difference between two lists of numbers or strings.
tf.compat.v1.setdiff1d(
    x, y, index_dtype=tf.dtypes.int32, name=None
)
 Given a list x and a list y, this operation returns a list out that represents all values that are in x but not in y. The returned list out is sorted in the same order that the numbers appear in x (duplicates are preserved). This operation also returns a list idx that represents the position of each out element in x. In other words: out[i] = x[idx[i]] for i in [0, 1, ..., len(out) - 1] For example, given this input: x = [1, 2, 3, 4, 5, 6]
y = [1, 3, 5]
 This operation would return: out ==> [2, 4, 6]
idx ==> [1, 3, 5]

 Args
  x   A Tensor. 1-D. Values to keep.
  y   A Tensor. Must have the same type as x. 1-D. Values to remove.
  out_idx   An optional tf.DType from: tf.int32, tf.int64. Defaults to tf.int32.
  name   A name for the operation (optional).

 Returns   A tuple of Tensor objects (out, idx).     out   A Tensor. Has the same type as x.
  idx   A Tensor of type out_idx.


Module: tf.compat.v1.sets Tensorflow set operations. Functions difference(...): Compute set difference of elements in last dimension of a and b. intersection(...): Compute set intersection of elements in last dimension of a and b. set_difference(...): Compute set difference of elements in last dimension of a and b. set_intersection(...): Compute set intersection of elements in last dimension of a and b. set_size(...): Compute number of unique elements along last dimension of a. set_union(...): Compute set union of elements in last dimension of a and b. size(...): Compute number of unique elements along last dimension of a. union(...): Compute set union of elements in last dimension of a and b.


tf.compat.v1.set_random_seed Sets the graph-level random seed for the default graph.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.random.set_random_seed
tf.compat.v1.set_random_seed(
    seed
)
 Operations that rely on a random seed actually derive it from two seeds: the graph-level and operation-level seeds. This sets the graph-level seed. Its interactions with operation-level seeds is as follows:  If neither the graph-level nor the operation seed is set: A random seed is used for this op. If the graph-level seed is set, but the operation seed is not: The system deterministically picks an operation seed in conjunction with the graph-level seed so that it gets a unique random sequence. Within the same version of tensorflow and user code, this sequence is deterministic. However across different versions, this sequence might change. If the code depends on particular seeds to work, specify both graph-level and operation-level seeds explicitly. If the graph-level seed is not set, but the operation seed is set: A default graph-level seed and the specified operation seed are used to determine the random sequence. If both the graph-level and the operation seed are set: Both seeds are used in conjunction to determine the random sequence.  To illustrate the user-visible effects, consider these examples: To generate different sequences across sessions, set neither graph-level nor op-level seeds: a = tf.random.uniform([1])
b = tf.random.normal([1])

print("Session 1")
with tf.compat.v1.Session() as sess1:
  print(sess1.run(a))  # generates 'A1'
  print(sess1.run(a))  # generates 'A2'
  print(sess1.run(b))  # generates 'B1'
  print(sess1.run(b))  # generates 'B2'

print("Session 2")
with tf.compat.v1.Session() as sess2:
  print(sess2.run(a))  # generates 'A3'
  print(sess2.run(a))  # generates 'A4'
  print(sess2.run(b))  # generates 'B3'
  print(sess2.run(b))  # generates 'B4'
 To generate the same repeatable sequence for an op across sessions, set the seed for the op: a = tf.random.uniform([1], seed=1)
b = tf.random.normal([1])

# Repeatedly running this block with the same graph will generate the same
# sequence of values for 'a', but different sequences of values for 'b'.
print("Session 1")
with tf.compat.v1.Session() as sess1:
  print(sess1.run(a))  # generates 'A1'
  print(sess1.run(a))  # generates 'A2'
  print(sess1.run(b))  # generates 'B1'
  print(sess1.run(b))  # generates 'B2'

print("Session 2")
with tf.compat.v1.Session() as sess2:
  print(sess2.run(a))  # generates 'A1'
  print(sess2.run(a))  # generates 'A2'
  print(sess2.run(b))  # generates 'B3'
  print(sess2.run(b))  # generates 'B4'
 To make the random sequences generated by all ops be repeatable across sessions, set a graph-level seed: tf.compat.v1.random.set_random_seed(1234)
a = tf.random.uniform([1])
b = tf.random.normal([1])

# Repeatedly running this block with the same graph will generate the same
# sequences of 'a' and 'b'.
print("Session 1")
with tf.compat.v1.Session() as sess1:
  print(sess1.run(a))  # generates 'A1'
  print(sess1.run(a))  # generates 'A2'
  print(sess1.run(b))  # generates 'B1'
  print(sess1.run(b))  # generates 'B2'

print("Session 2")
with tf.compat.v1.Session() as sess2:
  print(sess2.run(a))  # generates 'A1'
  print(sess2.run(a))  # generates 'A2'
  print(sess2.run(b))  # generates 'B1'
  print(sess2.run(b))  # generates 'B2'

 Args
  seed   integer.


tf.compat.v1.shape Returns the shape of a tensor.
tf.compat.v1.shape(
    input, name=None, out_type=tf.dtypes.int32
)
 This operation returns a 1-D integer tensor representing the shape of input. For example: t = tf.constant([[[1, 1, 1], [2, 2, 2]], [[3, 3, 3], [4, 4, 4]]])
tf.shape(t)  # [2, 2, 3]

 Args
  input   A Tensor or SparseTensor.
  name   A name for the operation (optional).
  out_type   (Optional) The specified output type of the operation (int32 or int64). Defaults to tf.int32.

 Returns   A Tensor of type out_type.


Module: tf.compat.v1.signal Signal processing operations. See the tf.signal guide. Functions dct(...): Computes the 1D [Discrete Cosine Transform (DCT)][dct] of input. fft(...): Fast Fourier transform. fft2d(...): 2D fast Fourier transform. fft3d(...): 3D fast Fourier transform. fftshift(...): Shift the zero-frequency component to the center of the spectrum. frame(...): Expands signal's axis dimension into frames of frame_length. hamming_window(...): Generate a Hamming window. hann_window(...): Generate a Hann window. idct(...): Computes the 1D [Inverse Discrete Cosine Transform (DCT)][idct] of input. ifft(...): Inverse fast Fourier transform. ifft2d(...): Inverse 2D fast Fourier transform. ifft3d(...): Inverse 3D fast Fourier transform. ifftshift(...): The inverse of fftshift. inverse_mdct(...): Computes the inverse modified DCT of mdcts. inverse_stft(...): Computes the inverse Short-time Fourier Transform of stfts. inverse_stft_window_fn(...): Generates a window function that can be used in inverse_stft. irfft(...): Inverse real-valued fast Fourier transform. irfft2d(...): Inverse 2D real-valued fast Fourier transform. irfft3d(...): Inverse 3D real-valued fast Fourier transform. kaiser_bessel_derived_window(...): Generate a [Kaiser Bessel derived window][kbd]. kaiser_window(...): Generate a [Kaiser window][kaiser]. linear_to_mel_weight_matrix(...): Returns a matrix to warp linear scale spectrograms to the mel scale. mdct(...): Computes the [Modified Discrete Cosine Transform][mdct] of signals. mfccs_from_log_mel_spectrograms(...): Computes MFCCs of log_mel_spectrograms. overlap_and_add(...): Reconstructs a signal from a framed representation. rfft(...): Real-valued fast Fourier transform. rfft2d(...): 2D real-valued fast Fourier transform. rfft3d(...): 3D real-valued fast Fourier transform. stft(...): Computes the Short-time Fourier Transform of signals. vorbis_window(...): Generate a [Vorbis power complementary window][vorbis].


tf.compat.v1.size Returns the size of a tensor.
tf.compat.v1.size(
    input, name=None, out_type=tf.dtypes.int32
)
 Returns a 0-D Tensor representing the number of elements in input of type out_type. Defaults to tf.int32. For example: t = tf.constant([[[1, 1, 1], [2, 2, 2]], [[3, 3, 3], [4, 4, 4]]])
tf.size(t)  # 12

 Args
  input   A Tensor or SparseTensor.
  name   A name for the operation (optional).
  out_type   (Optional) The specified non-quantized numeric output type of the operation. Defaults to tf.int32.

 Returns   A Tensor of type out_type. Defaults to tf.int32.
 Numpy Compatibility Equivalent to np.size()


tf.compat.v1.space_to_batch SpaceToBatch for 4-D tensors of type T.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.nn.space_to_batch
tf.compat.v1.space_to_batch(
    input, paddings, block_size=None, name=None, block_shape=None
)
 This is a legacy version of the more general SpaceToBatchND. Zero-pads and then rearranges (permutes) blocks of spatial data into batch. More specifically, this op outputs a copy of the input tensor where values from the height and width dimensions are moved to the batch dimension. After the zero-padding, both height and width of the input must be divisible by the block size.

 Args
  input   A Tensor. 4-D with shape [batch, height, width, depth].
  paddings   A Tensor. Must be one of the following types: int32, int64. 2-D tensor of non-negative integers with shape [2, 2]. It specifies the padding of the input with zeros across the spatial dimensions as follows: paddings = [[pad_top, pad_bottom], [pad_left, pad_right]] The effective spatial dimensions of the zero-padded input tensor will be: height_pad = pad_top + height + pad_bottom width_pad = pad_left + width + pad_right The attr block_size must be greater than one. It indicates the block size.  Non-overlapping blocks of size block_size x block size in the height and width dimensions are rearranged into the batch dimension at each location. The batch of the output tensor is batch * block_size * block_size. Both height_pad and width_pad must be divisible by block_size.  The shape of the output will be: [batchblock_sizeblock_size, height_pad/block_size, width_pad/block_size, depth] Some examples: (1) For the following input of shape [1, 2, 2, 1] and block_size of 2: x = [[[[1], [2]], [[3], [4]]]]
 The output tensor has shape [4, 1, 1, 1] and value: [[[[1]]], [[[2]]], [[[3]]], [[[4]]]]
 (2) For the following input of shape [1, 2, 2, 3] and block_size of 2: x = [[[[1, 2, 3], [4, 5, 6]],
[[7, 8, 9], [10, 11, 12]]]]
 The output tensor has shape [4, 1, 1, 3] and value: [[[[1, 2, 3]]], [[[4, 5, 6]]], [[[7, 8, 9]]], [[[10, 11, 12]]]]
 (3) For the following input of shape [1, 4, 4, 1] and block_size of 2: x = [[[[1],   [2],  [3],  [4]],
[[5],   [6],  [7],  [8]],
[[9],  [10], [11],  [12]],
[[13], [14], [15],  [16]]]]
 The output tensor has shape [4, 2, 2, 1] and value: x = [[[[1], [3]], [[9], [11]]],
[[[2], [4]], [[10], [12]]],
[[[5], [7]], [[13], [15]]],
[[[6], [8]], [[14], [16]]]]
 (4) For the following input of shape [2, 2, 4, 1] and block_size of 2: x = [[[[1],   [2],  [3],  [4]],
[[5],   [6],  [7],  [8]]],
[[[9],  [10], [11],  [12]],
[[13], [14], [15],  [16]]]]
 The output tensor has shape [8, 1, 2, 1] and value: x = [[[[1], [3]]], [[[9], [11]]], [[[2], [4]]], [[[10], [12]]],
[[[5], [7]]], [[[13], [15]]], [[[6], [8]]], [[[14], [16]]]]
 Among others, this operation is useful for reducing atrous convolution into regular convolution.

  block_size   An int that is >= 2.
  name   A name for the operation (optional).

 Returns   A Tensor. Has the same type as input.


tf.compat.v1.space_to_depth SpaceToDepth for tensors of type T.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.nn.space_to_depth
tf.compat.v1.space_to_depth(
    input, block_size, name=None, data_format='NHWC'
)
 Rearranges blocks of spatial data, into depth. More specifically, this op outputs a copy of the input tensor where values from the height and width dimensions are moved to the depth dimension. The attr block_size indicates the input block size.  Non-overlapping blocks of size block_size x block size are rearranged into depth at each location. The depth of the output tensor is block_size * block_size * input_depth. The Y, X coordinates within each block of the input become the high order component of the output channel index. The input tensor's height and width must be divisible by block_size.  The data_format attr specifies the layout of the input and output tensors with the following options: "NHWC": [ batch, height, width, channels ] "NCHW": [ batch, channels, height, width ] "NCHW_VECT_C": qint8 [ batch, channels / 4, height, width, 4 ] It is useful to consider the operation as transforming a 6-D Tensor. e.g. for data_format = NHWC, Each element in the input tensor can be specified via 6 coordinates, ordered by decreasing memory layout significance as: n,oY,bY,oX,bX,iC (where n=batch index, oX, oY means X or Y coordinates within the output image, bX, bY means coordinates within the input block, iC means input channels). The output would be a transpose to the following layout: n,oY,oX,bY,bX,iC This operation is useful for resizing the activations between convolutions (but keeping all data), e.g. instead of pooling. It is also useful for training purely convolutional models. For example, given an input of shape [1, 2, 2, 1], data_format = "NHWC" and block_size = 2: x = [[[[1], [2]],
      [[3], [4]]]]
 This operation will output a tensor of shape [1, 1, 1, 4]: [[[[1, 2, 3, 4]]]]
 Here, the input has a batch of 1 and each batch element has shape [2, 2, 1], the corresponding output will have a single element (i.e. width and height are both 1) and will have a depth of 4 channels (1 * block_size * block_size). The output element shape is [1, 1, 4]. For an input tensor with larger depth, here of shape [1, 2, 2, 3], e.g. x = [[[[1, 2, 3], [4, 5, 6]],
      [[7, 8, 9], [10, 11, 12]]]]
 This operation, for block_size of 2, will return the following tensor of shape [1, 1, 1, 12] [[[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]]]]
 Similarly, for the following input of shape [1 4 4 1], and a block size of 2: x = [[[[1],   [2],  [5],  [6]],
      [[3],   [4],  [7],  [8]],
      [[9],  [10], [13],  [14]],
      [[11], [12], [15],  [16]]]]
 the operator will return the following tensor of shape [1 2 2 4]: x = [[[[1, 2, 3, 4],
       [5, 6, 7, 8]],
      [[9, 10, 11, 12],
       [13, 14, 15, 16]]]]

 Args
  input   A Tensor.
  block_size   An int that is >= 2. The size of the spatial block.
  data_format   An optional string from: "NHWC", "NCHW", "NCHW_VECT_C". Defaults to "NHWC".
  name   A name for the operation (optional).

 Returns   A Tensor. Has the same type as input.