tf.lookup.TextFileInitializer     View source on GitHub    Table initializers from a text file.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.lookup.TextFileInitializer
tf.lookup.TextFileInitializer(
    filename, key_dtype, key_index, value_dtype, value_index, vocab_size=None,
    delimiter='\t', name=None
)
 This initializer assigns one entry in the table for each line in the file. The key and value type of the table to initialize is given by key_dtype and value_dtype. The key and value content to get from each line is specified by the key_index and value_index.
TextFileIndex.LINE_NUMBER means use the line number starting from zero, expects data type int64.
TextFileIndex.WHOLE_LINE means use the whole line content, expects data type string. A value >=0 means use the index (starting at zero) of the split line based on delimiter.  For example if we have a file with the following content:
import tempfile
f = tempfile.NamedTemporaryFile(delete=False)
content='\n'.join(["emerson 10", "lake 20", "palmer 30",])
f.file.write(content.encode('utf-8'))
f.file.close()
 The following snippet initializes a table with the first column as keys and second column as values:  emerson -> 10 lake -> 20 palmer -> 30
init= tf.lookup.TextFileInitializer(
   filename=f.name,
   key_dtype=tf.string, key_index=0,
   value_dtype=tf.int64, value_index=1,
   delimiter=" ")
table = tf.lookup.StaticHashTable(init, default_value=-1)
table.lookup(tf.constant(['palmer','lake','tarkus'])).numpy()
 Similarly to initialize the whole line as keys and the line number as values.  emerson 10 -> 0 lake 20 -> 1 palmer 30 -> 2
init = tf.lookup.TextFileInitializer(
  filename=f.name,
  key_dtype=tf.string, key_index=tf.lookup.TextFileIndex.WHOLE_LINE,
  value_dtype=tf.int64, value_index=tf.lookup.TextFileIndex.LINE_NUMBER,
  delimiter=" ")
table = tf.lookup.StaticHashTable(init, -1)
table.lookup(tf.constant('palmer 30')).numpy()
2

 Args
  filename   The filename of the text file to be used for initialization. The path must be accessible from wherever the graph is initialized (eg. trainer or eval workers). The filename may be a scalar Tensor.
  key_dtype   The key data type.
  key_index   the index that represents information of a line to get the table 'key' values from.
  value_dtype   The value data type.
  value_index   the index that represents information of a line to get the table 'value' values from.'
  vocab_size   The number of elements in the file, if known.
  delimiter   The delimiter to separate fields in a line.
  name   A name for the operation (optional).

 Raises
  ValueError   when the filename is empty, or when the table key and value data types do not match the expected data types.

 Attributes
  key_dtype   The expected table key dtype.
  value_dtype   The expected table value dtype.    Methods initialize View source
initialize(
    table
)
 Initializes the table from a text file.

 Args
  table   The table to be initialized.

 Returns   The operation that initializes the table.

 Raises
  TypeError   when the keys and values data types do not match the table key and value data types.


tf.make_ndarray     View source on GitHub    Create a numpy ndarray from a tensor.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.make_ndarray
tf.make_ndarray(
    tensor
)
 Create a numpy ndarray with the same shape and data as the tensor. For example: # Tensor a has shape (2,3)
a = tf.constant([[1,2,3],[4,5,6]])
proto_tensor = tf.make_tensor_proto(a)  # convert `tensor a` to a proto tensor
tf.make_ndarray(proto_tensor) # output: array([[1, 2, 3],
#                                              [4, 5, 6]], dtype=int32)
# output has shape (2,3)

 Args
  tensor   A TensorProto.

 Returns   A numpy array with the tensor contents.

 Raises
  TypeError   if tensor has unsupported type.


tf.make_tensor_proto     View source on GitHub    Create a TensorProto.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.make_tensor_proto
tf.make_tensor_proto(
    values, dtype=None, shape=None, verify_shape=False, allow_broadcast=False
)
 In TensorFlow 2.0, representing tensors as protos should no longer be a common workflow. That said, this utility function is still useful for generating TF Serving request protos: request = tensorflow_serving.apis.predict_pb2.PredictRequest()
request.model_spec.name = "my_model"
request.model_spec.signature_name = "serving_default"
request.inputs["images"].CopyFrom(tf.make_tensor_proto(X_new))
 make_tensor_proto accepts "values" of a python scalar, a python list, a numpy ndarray, or a numpy scalar. If "values" is a python scalar or a python list, make_tensor_proto first convert it to numpy ndarray. If dtype is None, the conversion tries its best to infer the right numpy data type. Otherwise, the resulting numpy array has a compatible data type with the given dtype. In either case above, the numpy ndarray (either the caller provided or the auto-converted) must have the compatible type with dtype. make_tensor_proto then converts the numpy array to a tensor proto. If "shape" is None, the resulting tensor proto represents the numpy array precisely. Otherwise, "shape" specifies the tensor's shape and the numpy array can not have more elements than what "shape" specifies.

 Args
  values   Values to put in the TensorProto.
  dtype   Optional tensor_pb2 DataType value.
  shape   List of integers representing the dimensions of tensor.
  verify_shape   Boolean that enables verification of a shape of values.
  allow_broadcast   Boolean that enables allowing scalars and 1 length vector broadcasting. Cannot be true when verify_shape is true.

 Returns   A TensorProto. Depending on the type, it may contain data in the "tensor_content" attribute, which is not directly useful to Python programs. To access the values you should convert the proto back to a numpy ndarray with tf.make_ndarray(proto). If values is a TensorProto, it is immediately returned; dtype and shape are ignored.

 Raises
  TypeError   if unsupported types are provided.
  ValueError   if arguments have inappropriate values or if verify_shape is True and shape of values is not equals to a shape from the argument.


tf.map_fn     View source on GitHub    Transforms elems by applying fn to each element unstacked on axis 0. (deprecated arguments)
tf.map_fn(
    fn, elems, dtype=None, parallel_iterations=None, back_prop=True,
    swap_memory=False, infer_shape=True, name=None, fn_output_signature=None
)
 Warning: SOME ARGUMENTS ARE DEPRECATED: (dtype). They will be removed in a future version. Instructions for updating: Use fn_output_signature instead See also tf.scan. map_fn unstacks elems on axis 0 to obtain a sequence of elements; calls fn to transform each element; and then stacks the transformed values back together. Mapping functions with single-Tensor inputs and outputs If elems is a single tensor and fn's signature is tf.Tensor->tf.Tensor, then map_fn(fn, elems) is equivalent to tf.stack([fn(elem) for elem in tf.unstack(elems)]). E.g.:
tf.map_fn(fn=lambda t: tf.range(t, t + 3), elems=tf.constant([3, 5, 2]))
<tf.Tensor: shape=(3, 3), dtype=int32, numpy=
  array([[3, 4, 5],
         [5, 6, 7],
         [2, 3, 4]], dtype=int32)>
 map_fn(fn, elems).shape = [elems.shape[0]] + fn(elems[0]).shape. Mapping functions with multi-arity inputs and outputs map_fn also supports functions with multi-arity inputs and outputs:  If elems is a tuple (or nested structure) of tensors, then those tensors must all have the same outer-dimension size (num_elems); and fn is used to transform each tuple (or structure) of corresponding slices from elems. E.g., if elems is a tuple (t1, t2, t3), then fn is used to transform each tuple of slices (t1[i], t2[i], t3[i]) (where 0 <= i < num_elems). If fn returns a tuple (or nested structure) of tensors, then the result is formed by stacking corresponding elements from those structures.  Specifying fn's output signature If fn's input and output signatures are different, then the output signature must be specified using fn_output_signature. (The input and output signatures are differ if their structures, dtypes, or tensor types do not match). E.g.:
tf.map_fn(fn=tf.strings.length,  # input & output have different dtypes
          elems=tf.constant(["hello", "moon"]),
          fn_output_signature=tf.int32)
<tf.Tensor: shape=(2,), dtype=int32, numpy=array([5, 4], dtype=int32)>
tf.map_fn(fn=tf.strings.join,  # input & output have different structures
          elems=[tf.constant(['The', 'A']), tf.constant(['Dog', 'Cat'])],
          fn_output_signature=tf.string)
<tf.Tensor: shape=(2,), dtype=string,
 numpy=array([b'TheDog', b'ACat'], dtype=object)>
 fn_output_signature can be specified using any of the following:  A tf.DType or tf.TensorSpec (to describe a tf.Tensor) A tf.RaggedTensorSpec (to describe a tf.RaggedTensor) A tf.SparseTensorSpec (to describe a tf.sparse.SparseTensor) A (possibly nested) tuple, list, or dict containing the above types.  RaggedTensors map_fn supports tf.RaggedTensor inputs and outputs. In particular:
If elems is a RaggedTensor, then fn will be called with each row of that ragged tensor.  If elems has only one ragged dimension, then the values passed to fn will be tf.Tensors. If elems has multiple ragged dimensions, then the values passed to fn will be tf.RaggedTensors with one fewer ragged dimension.

If the result of map_fn should be a RaggedTensor, then use a tf.RaggedTensorSpec to specify fn_output_signature.  If fn returns tf.Tensors with varying sizes, then use a tf.RaggedTensorSpec with ragged_rank=0 to combine them into a single ragged tensor (which will have ragged_rank=1). If fn returns tf.RaggedTensors, then use a tf.RaggedTensorSpec with the same ragged_rank.

# Example: RaggedTensor input
rt = tf.ragged.constant([[1, 2, 3], [], [4, 5], [6]])
tf.map_fn(tf.reduce_sum, rt, fn_output_signature=tf.int32)
<tf.Tensor: shape=(4,), dtype=int32, numpy=array([6, 0, 9, 6], dtype=int32)>

# Example: RaggedTensor output
elems = tf.constant([3, 5, 0, 2])
tf.map_fn(tf.range, elems,
          fn_output_signature=tf.RaggedTensorSpec(shape=[None],
                                                  dtype=tf.int32))
<tf.RaggedTensor [[0, 1, 2], [0, 1, 2, 3, 4], [], [0, 1]]>

Note: map_fn should only be used if you need to map a function over the rows of a RaggedTensor. If you wish to map a function over the individual values, then you should use:

tf.ragged.map_flat_values(fn, rt) (if fn is expressible as TensorFlow ops)
rt.with_flat_values(map_fn(fn, rt.flat_values)) (otherwise)  E.g.:
rt = tf.ragged.constant([[1, 2, 3], [], [4, 5], [6]])
tf.ragged.map_flat_values(lambda x: x + 2, rt)
<tf.RaggedTensor [[3, 4, 5], [], [6, 7], [8]]>
 SparseTensors map_fn supports tf.sparse.SparseTensor inputs and outputs. In particular:  If elems is a SparseTensor, then fn will be called with each row of that sparse tensor. In particular, the value passed to fn will be a tf.sparse.SparseTensor with one fewer dimension than elems. If the result of map_fn should be a SparseTensor, then use a tf.SparseTensorSpec to specify fn_output_signature. The individual SparseTensors returned by fn will be stacked into a single SparseTensor with one more dimension.
# Example: SparseTensor input
st = tf.sparse.SparseTensor([[0, 0], [2, 0], [2, 1]], [2, 3, 4], [4, 4])
tf.map_fn(tf.sparse.reduce_sum, st, fn_output_signature=tf.int32)
<tf.Tensor: shape=(4,), dtype=int32, numpy=array([2, 0, 7, 0], dtype=int32)>

# Example: SparseTensor output
tf.sparse.to_dense(
    tf.map_fn(tf.sparse.eye, tf.constant([2, 3]),
              fn_output_signature=tf.SparseTensorSpec(None, tf.float32)))
<tf.Tensor: shape=(2, 3, 3), dtype=float32, numpy=
  array([[[1., 0., 0.],
          [0., 1., 0.],
          [0., 0., 0.]],
         [[1., 0., 0.],
          [0., 1., 0.],
          [0., 0., 1.]]], dtype=float32)>

Note: map_fn should only be used if you need to map a function over the rows of a SparseTensor. If you wish to map a function over the nonzero values, then you should use:

If the function is expressible as TensorFlow ops, use: tf.sparse.SparseTensor(st.indices, fn(st.values), st.dense_shape)

Otherwise, use: tf.sparse.SparseTensor(st.indices, tf.map_fn(fn, st.values),
                       st.dense_shape)

map_fn vs. vectorized operations map_fn will apply the operations used by fn to each element of elems, resulting in O(elems.shape[0]) total operations. This is somewhat mitigated by the fact that map_fn can process elements in parallel. However, a transform expressed using map_fn is still typically less efficient than an equivalent transform expressed using vectorized operations. map_fn should typically only be used if one of the following is true:  It is difficult or expensive to express the desired transform with vectorized operations.
fn creates large intermediate values, so an equivalent vectorized transform would take too much memory. Processing elements in parallel is more efficient than an equivalent vectorized transform. Efficiency of the transform is not critical, and using map_fn is more readable.  E.g., the example given above that maps fn=lambda t: tf.range(t, t + 3) across elems could be rewritten more efficiently using vectorized ops:
elems = tf.constant([3, 5, 2])
tf.range(3) + tf.expand_dims(elems, 1)
<tf.Tensor: shape=(3, 3), dtype=int32, numpy=
  array([[3, 4, 5],
         [5, 6, 7],
         [2, 3, 4]], dtype=int32)>
 In some cases, tf.vectorized_map can be used to automatically convert a function to a vectorized eqivalent. Eager execution When executing eagerly, map_fn does not execute in parallel even if parallel_iterations is set to a value > 1. You can still get the performance benefits of running a function in parallel by using the tf.function decorator:
fn=lambda t: tf.range(t, t + 3)
@tf.function
def func(elems):
  return tf.map_fn(fn, elems, parallel_iterations=3)
func(tf.constant([3, 5, 2]))
<tf.Tensor: shape=(3, 3), dtype=int32, numpy=
  array([[3, 4, 5],
         [5, 6, 7],
         [2, 3, 4]], dtype=int32)>

Note: if you use the tf.function decorator, any non-TensorFlow Python code that you may have written in your function won't get executed. See tf.function for more details. The recommendation would be to debug without tf.function but switch to it to get performance benefits of running map_fn in parallel.

 Args
  fn   The callable to be performed. It accepts one argument, which will have the same (possibly nested) structure as elems. Its output must have the same structure as fn_output_signature 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 unstacked along their first dimension. fn will be applied to the nested sequence of the resulting slices. elems may include ragged and sparse tensors. elems must consist of at least one tensor.
  dtype   Deprecated: Equivalent to fn_output_signature.
  parallel_iterations   (optional) The number of iterations allowed to run in parallel. When graph building, the default value is 10. While executing eagerly, the default value is set to 1.
  back_prop   (optional) Deprecated: prefer using tf.stop_gradient instead. False disables support for back propagation.
  swap_memory   (optional) True enables GPU-CPU memory swapping.
  infer_shape   (optional) False disables tests for consistent output shapes.
  name   (optional) Name prefix for the returned tensors.
  fn_output_signature   The output signature of fn. Must be specified if fn's input and output signatures are different (i.e., if their structures, dtypes, or tensor types do not match). fn_output_signature can be specified using any of the following:  A tf.DType or tf.TensorSpec (to describe a tf.Tensor) A tf.RaggedTensorSpec (to describe a tf.RaggedTensor) A tf.SparseTensorSpec (to describe a tf.sparse.SparseTensor) A (possibly nested) tuple, list, or dict containing the above types.

 Returns   A tensor or (possibly nested) sequence of tensors. Each tensor stacks the results of applying fn to tensors unstacked from elems along the first dimension, from first to last. The result may include ragged and sparse tensors.

 Raises
  TypeError   if fn is not callable or the structure of the output of fn and fn_output_signature do not match.
  ValueError   if the lengths of the output of fn and fn_output_signature do not match, or if the elems does not contain any tensor.    Examples:
elems = np.array([1, 2, 3, 4, 5, 6])
tf.map_fn(lambda x: x * x, elems)
<tf.Tensor: shape=(6,), dtype=int64, numpy=array([ 1,  4,  9, 16, 25, 36])>

elems = (np.array([1, 2, 3]), np.array([-1, 1, -1]))
tf.map_fn(lambda x: x[0] * x[1], elems, fn_output_signature=tf.int64)
<tf.Tensor: shape=(3,), dtype=int64, numpy=array([-1,  2, -3])>

elems = np.array([1, 2, 3])
tf.map_fn(lambda x: (x, -x), elems,
         fn_output_signature=(tf.int64, tf.int64))
(<tf.Tensor: shape=(3,), dtype=int64, numpy=array([1, 2, 3])>,
 <tf.Tensor: shape=(3,), dtype=int64, numpy=array([-1, -2, -3])>)


Module: tf.math   Math Operations.
Note: Functions taking Tensor arguments can also take anything accepted by tf.convert_to_tensor.

Note: Elementwise binary operations in TensorFlow follow numpy-style broadcasting.
 TensorFlow provides a variety of math functions including:  Basic arithmetic operators and trigonometric functions. Special math functions (like: tf.math.igamma and tf.math.zeta) Complex number functions (like: tf.math.imag and tf.math.angle) Reductions and scans (like: tf.math.reduce_mean and tf.math.cumsum) Segment functions (like: tf.math.segment_sum)  See: tf.linalg for matrix and tensor functions. About Segmentation TensorFlow provides several operations that you can use to perform common math computations on tensor segments. Here a segmentation is a partitioning of a tensor along the first dimension, i.e. it defines a mapping from the first dimension onto segment_ids. The segment_ids tensor should be the size of the first dimension, d0, with consecutive IDs in the range 0 to k, where k<d0. In particular, a segmentation of a matrix tensor is a mapping of rows to segments. For example: c = tf.constant([[1,2,3,4], [-1,-2,-3,-4], [5,6,7,8]])
tf.math.segment_sum(c, tf.constant([0, 0, 1]))
#  ==>  [[0 0 0 0]
#        [5 6 7 8]]
 The standard segment_* functions assert that the segment indices are sorted. If you have unsorted indices use the equivalent unsorted_segment_ function. These functions take an additional argument num_segments so that the output tensor can be efficiently allocated. c = tf.constant([[1,2,3,4], [-1,-2,-3,-4], [5,6,7,8]])
tf.math.unsorted_segment_sum(c, tf.constant([0, 1, 0]), num_segments=2)
# ==> [[ 6,  8, 10, 12],
#       [-1, -2, -3, -4]]
 Modules special module: Public API for tf.math.special namespace. Functions abs(...): Computes the absolute value of a tensor. accumulate_n(...): Returns the element-wise sum of a list of tensors. acos(...): Computes acos of x element-wise. acosh(...): Computes inverse hyperbolic cosine of x element-wise. add(...): Returns x + y element-wise. add_n(...): Adds all input tensors element-wise. angle(...): Returns the element-wise argument of a complex (or real) tensor. argmax(...): Returns the index with the largest value across axes of a tensor. argmin(...): Returns the index with the smallest value across axes of a tensor. asin(...): Computes the trignometric inverse sine of x element-wise. asinh(...): Computes inverse hyperbolic sine of x element-wise. atan(...): Computes the trignometric inverse tangent of x element-wise. atan2(...): Computes arctangent of y/x element-wise, respecting signs of the arguments. atanh(...): Computes inverse hyperbolic tangent of x element-wise. bessel_i0(...): Computes the Bessel i0 function of x element-wise. bessel_i0e(...): Computes the Bessel i0e function of x element-wise. bessel_i1(...): Computes the Bessel i1 function of x element-wise. bessel_i1e(...): Computes the Bessel i1e function of x element-wise. betainc(...): Compute the regularized incomplete beta integral \(I_x(a, b)\). bincount(...): Counts the number of occurrences of each value in an integer array. ceil(...): Return the ceiling of the input, element-wise. confusion_matrix(...): Computes the confusion matrix from predictions and labels. conj(...): Returns the complex conjugate of a complex number. cos(...): Computes cos of x element-wise. cosh(...): Computes hyperbolic cosine of x element-wise. count_nonzero(...): Computes number of nonzero elements across dimensions of a tensor. cumprod(...): Compute the cumulative product of the tensor x along axis. cumsum(...): Compute the cumulative sum of the tensor x along axis. cumulative_logsumexp(...): Compute the cumulative log-sum-exp of the tensor x along axis. digamma(...): Computes Psi, the derivative of Lgamma (the log of the absolute value of divide(...): Computes Python style division of x by y. divide_no_nan(...): Computes a safe divide which returns 0 if the y is zero. equal(...): Returns the truth value of (x == y) element-wise. erf(...): Computes the Gauss error function of x element-wise. erfc(...): Computes the complementary error function of x element-wise. erfcinv(...): Computes the inverse of complementary error function. erfinv(...): Compute inverse error function. exp(...): Computes exponential of x element-wise. \(y = e^x\). expm1(...): Computes exp(x) - 1 element-wise. floor(...): Returns element-wise largest integer not greater than x. floordiv(...): Divides x / y elementwise, rounding toward the most negative integer. floormod(...): Returns element-wise remainder of division. When x < 0 xor y < 0 is greater(...): Returns the truth value of (x > y) element-wise. greater_equal(...): Returns the truth value of (x >= y) element-wise. igamma(...): Compute the lower regularized incomplete Gamma function P(a, x). igammac(...): Compute the upper regularized incomplete Gamma function Q(a, x). imag(...): Returns the imaginary part of a complex (or real) tensor. in_top_k(...): Says whether the targets are in the top K predictions. invert_permutation(...): Computes the inverse permutation of a tensor. is_finite(...): Returns which elements of x are finite. is_inf(...): Returns which elements of x are Inf. is_nan(...): Returns which elements of x are NaN. is_non_decreasing(...): Returns True if x is non-decreasing. is_strictly_increasing(...): Returns True if x is strictly increasing. l2_normalize(...): Normalizes along dimension axis using an L2 norm. lbeta(...): Computes \(ln(|Beta(x)|)\), reducing along the last dimension. less(...): Returns the truth value of (x < y) element-wise. less_equal(...): Returns the truth value of (x <= y) element-wise. lgamma(...): Computes the log of the absolute value of Gamma(x) element-wise. log(...): Computes natural logarithm of x element-wise. log1p(...): Computes natural logarithm of (1 + x) element-wise. log_sigmoid(...): Computes log sigmoid of x element-wise. log_softmax(...): Computes log softmax activations. logical_and(...): Logical AND function. logical_not(...): Returns the truth value of NOT x element-wise. logical_or(...): Returns the truth value of x OR y element-wise. logical_xor(...): Logical XOR function. maximum(...): Returns the max of x and y (i.e. x > y ? x : y) element-wise. minimum(...): Returns the min of x and y (i.e. x < y ? x : y) element-wise. mod(...): Returns element-wise remainder of division. When x < 0 xor y < 0 is multiply(...): Returns an element-wise x * y. multiply_no_nan(...): Computes the product of x and y and returns 0 if the y is zero, even if x is NaN or infinite. ndtri(...): Compute quantile of Standard Normal. negative(...): Computes numerical negative value element-wise. nextafter(...): Returns the next representable value of x1 in the direction of x2, element-wise. not_equal(...): Returns the truth value of (x != y) element-wise. polygamma(...): Compute the polygamma function \(\psi^{(n)}(x)\). polyval(...): Computes the elementwise value of a polynomial. pow(...): Computes the power of one value to another. real(...): Returns the real part of a complex (or real) tensor. reciprocal(...): Computes the reciprocal of x element-wise. reciprocal_no_nan(...): Performs a safe reciprocal operation, element wise. reduce_all(...): Computes the "logical and" of elements across dimensions of a tensor. reduce_any(...): Computes the "logical or" of elements across dimensions of a tensor. reduce_euclidean_norm(...): Computes the Euclidean norm of elements across dimensions of a tensor. reduce_logsumexp(...): Computes log(sum(exp(elements across dimensions of a tensor))). reduce_max(...): Computes the maximum of elements across dimensions of a tensor. reduce_mean(...): Computes the mean of elements across dimensions of a tensor. reduce_min(...): Computes the minimum of elements across dimensions of a tensor. reduce_prod(...): Computes the product of elements across dimensions of a tensor. reduce_std(...): Computes the standard deviation of elements across dimensions of a tensor. reduce_sum(...): Computes the sum of elements across dimensions of a tensor. reduce_variance(...): Computes the variance of elements across dimensions of a tensor. rint(...): Returns element-wise integer closest to x. round(...): Rounds the values of a tensor to the nearest integer, element-wise. rsqrt(...): Computes reciprocal of square root of x element-wise. scalar_mul(...): Multiplies a scalar times a Tensor or IndexedSlices object. segment_max(...): Computes the maximum along segments of a tensor. segment_mean(...): Computes the mean along segments of a tensor. segment_min(...): Computes the minimum along segments of a tensor. segment_prod(...): Computes the product along segments of a tensor. segment_sum(...): Computes the sum along segments of a tensor. sigmoid(...): Computes sigmoid of x element-wise. sign(...): Returns an element-wise indication of the sign of a number. sin(...): Computes sine of x element-wise. sinh(...): Computes hyperbolic sine of x element-wise. sobol_sample(...): Generates points from the Sobol sequence. softmax(...): Computes softmax activations. softplus(...): Computes softplus: log(exp(features) + 1). softsign(...): Computes softsign: features / (abs(features) + 1). sqrt(...): Computes element-wise square root of the input tensor. square(...): Computes square of x element-wise. squared_difference(...): Returns conj(x - y)(x - y) element-wise. subtract(...): Returns x - y element-wise. tan(...): Computes tan of x element-wise. tanh(...): Computes hyperbolic tangent of x element-wise. top_k(...): Finds values and indices of the k largest entries for the last dimension. truediv(...): Divides x / y elementwise (using Python 3 division operator semantics). unsorted_segment_max(...): Computes the maximum along segments of a tensor. unsorted_segment_mean(...): Computes the mean along segments of a tensor. unsorted_segment_min(...): Computes the minimum along segments of a tensor. unsorted_segment_prod(...): Computes the product along segments of a tensor. unsorted_segment_sqrt_n(...): Computes the sum along segments of a tensor divided by the sqrt(N). unsorted_segment_sum(...): Computes the sum along segments of a tensor. xdivy(...): Returns 0 if x == 0, and x / y otherwise, elementwise. xlog1py(...): Compute x * log1p(y). xlogy(...): Returns 0 if x == 0, and x * log(y) otherwise, elementwise. zero_fraction(...): Returns the fraction of zeros in value. zeta(...): Compute the Hurwitz zeta function \(\zeta(x, q)\).


tf.math.abs       View source on GitHub    Computes the absolute value of a tensor.  View aliases  Main aliases
tf.abs Compat aliases for migration See Migration guide for more details. tf.compat.v1.abs, tf.compat.v1.math.abs
tf.math.abs(
    x, name=None
)
 Given a tensor of integer or floating-point values, this operation returns a tensor of the same type, where each element contains the absolute value of the corresponding element in the input. Given a tensor x of complex numbers, this operation returns a tensor of type float32 or float64 that is the absolute value of each element in x. For a complex number \(a + bj\), its absolute value is computed as \(\sqrt{a^2 + b^2}\). For example:
# real number
x = tf.constant([-2.25, 3.25])
tf.abs(x)
<tf.Tensor: shape=(2,), dtype=float32,
numpy=array([2.25, 3.25], dtype=float32)>

# complex number
x = tf.constant([[-2.25 + 4.75j], [-3.25 + 5.75j]])
tf.abs(x)
<tf.Tensor: shape=(2, 1), dtype=float64, numpy=
array([[5.25594901],
       [6.60492241]])>

 Args
  x   A Tensor or SparseTensor of type float16, float32, float64, int32, int64, complex64 or complex128.
  name   A name for the operation (optional).

 Returns   A Tensor or SparseTensor of the same size, type and sparsity as x, with absolute values. Note, for complex64 or complex128 input, the returned Tensor will be of type float32 or float64, respectively. If x is a SparseTensor, returns SparseTensor(x.indices, tf.math.abs(x.values, ...), x.dense_shape)


tf.math.accumulate_n     View source on GitHub    Returns the element-wise sum of a list of tensors.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.accumulate_n, tf.compat.v1.math.accumulate_n
tf.math.accumulate_n(
    inputs, shape=None, tensor_dtype=None, name=None
)
 Optionally, pass shape and tensor_dtype for shape and type checking, otherwise, these are inferred. accumulate_n performs the same operation as tf.math.add_n. For example: a = tf.constant([[1, 2], [3, 4]])
b = tf.constant([[5, 0], [0, 6]])
tf.math.accumulate_n([a, b, a])  # [[7, 4], [6, 14]]

# Explicitly pass shape and type
tf.math.accumulate_n([a, b, a], shape=[2, 2], tensor_dtype=tf.int32)
                                                               # [[7,  4],
                                                               #  [6, 14]]

 Args
  inputs   A list of Tensor objects, each with same shape and type.
  shape   Expected shape of elements of inputs (optional). Also controls the output shape of this op, which may affect type inference in other ops. A value of None means "infer the input shape from the shapes in inputs".
  tensor_dtype   Expected data type of inputs (optional). A value of None means "infer the input dtype from inputs[0]".
  name   A name for the operation (optional).

 Returns   A Tensor of same shape and type as the elements of inputs.

 Raises
  ValueError   If inputs don't all have same shape and dtype or the shape cannot be inferred.


tf.math.acos     View source on GitHub    Computes acos of x element-wise.  View aliases  Main aliases
tf.acos Compat aliases for migration See Migration guide for more details. tf.compat.v1.acos, tf.compat.v1.math.acos
tf.math.acos(
    x, name=None
)
 Provided an input tensor, the tf.math.acos operation returns the inverse cosine of each element of the tensor. If y = tf.math.cos(x) then, x = tf.math.acos(y). Input range is [-1, 1] and the output has a range of [0, pi]. For example:
x = tf.constant([1.0, -0.5, 3.4, 0.2, 0.0, -2], dtype = tf.float32)
tf.math.acos(x)
<tf.Tensor: shape=(6,), dtype=float32,
numpy= array([0. , 2.0943952, nan, 1.3694383, 1.5707964, nan],
dtype=float32)>

 Args
  x   A Tensor. Must be one of the following types: bfloat16, half, float32, float64, uint8, int8, int16, int32, int64, complex64, complex128, string.
  name   A name for the operation (optional).

 Returns   A Tensor. Has the same type as x.


tf.math.acosh Computes inverse hyperbolic cosine of x element-wise.  View aliases  Main aliases
tf.acosh Compat aliases for migration See Migration guide for more details. tf.compat.v1.acosh, tf.compat.v1.math.acosh
tf.math.acosh(
    x, name=None
)
 Given an input tensor, the function computes inverse hyperbolic cosine of every element. Input range is [1, inf]. It returns nan if the input lies outside the range. x = tf.constant([-2, -0.5, 1, 1.2, 200, 10000, float("inf")])
tf.math.acosh(x) ==> [nan nan 0. 0.62236255 5.9914584 9.903487 inf]

 Args
  x   A Tensor. Must be one of the following types: bfloat16, half, float32, float64, complex64, complex128.
  name   A name for the operation (optional).

 Returns   A Tensor. Has the same type as x.


tf.math.add Returns x + y element-wise.  View aliases  Main aliases
tf.add Compat aliases for migration See Migration guide for more details. tf.compat.v1.add, tf.compat.v1.math.add
tf.math.add(
    x, y, name=None
)

Note: math.add supports broadcasting. AddN does not. More about broadcasting here
 Given two input tensors, the tf.add operation computes the sum for every element in the tensor. Both input and output have a range (-inf, inf).

 Args
  x   A Tensor. Must be one of the following types: bfloat16, half, float32, float64, uint8, int8, int16, int32, int64, complex64, complex128, string.
  y   A Tensor. Must have the same type as x.
  name   A name for the operation (optional).

 Returns   A Tensor. Has the same type as x.


tf.math.add_n     View source on GitHub    Adds all input tensors element-wise.  View aliases  Main aliases
tf.add_n Compat aliases for migration See Migration guide for more details. tf.compat.v1.add_n, tf.compat.v1.math.add_n
tf.math.add_n(
    inputs, name=None
)
 tf.math.add_n performs the same operation as tf.math.accumulate_n, but it waits for all of its inputs to be ready before beginning to sum. This buffering can result in higher memory consumption when inputs are ready at different times, since the minimum temporary storage required is proportional to the input size rather than the output size. This op does not broadcast its inputs. If you need broadcasting, use tf.math.add (or the + operator) instead. For example:
a = tf.constant([[3, 5], [4, 8]])
b = tf.constant([[1, 6], [2, 9]])
tf.math.add_n([a, b, a])
<tf.Tensor: shape=(2, 2), dtype=int32, numpy=
array([[ 7, 16],
       [10, 25]], dtype=int32)>

 Args
  inputs   A list of tf.Tensor or tf.IndexedSlices objects, each with the same shape and type. tf.IndexedSlices objects will be converted into dense tensors prior to adding.
  name   A name for the operation (optional).

 Returns   A tf.Tensor of the same shape and type as the elements of inputs.

 Raises
  ValueError   If inputs don't all have same shape and dtype or the shape cannot be inferred.


tf.math.angle       View source on GitHub    Returns the element-wise argument of a complex (or real) tensor.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.angle, tf.compat.v1.math.angle
tf.math.angle(
    input, name=None
)
 Given a tensor input, this operation returns a tensor of type float that is the argument of each element in input considered as a complex number. The elements in input are considered to be complex numbers of the form \(a + bj\), where a is the real part and b is the imaginary part. If input is real then b is zero by definition. The argument returned by this function is of the form \(atan2(b, a)\). If input is real, a tensor of all zeros is returned. For example: input = tf.constant([-2.25 + 4.75j, 3.25 + 5.75j], dtype=tf.complex64)
tf.math.angle(input).numpy()
# ==> array([2.0131705, 1.056345 ], dtype=float32)

 Args
  input   A Tensor. Must be one of the following types: float, double, complex64, complex128.
  name   A name for the operation (optional).

 Returns   A Tensor of type float32 or float64.


tf.math.argmax     View source on GitHub    Returns the index with the largest value across axes of a tensor.  View aliases  Main aliases
tf.argmax
tf.math.argmax(
    input, axis=None, output_type=tf.dtypes.int64, name=None
)
 In case of identity returns the smallest index. For example:
A = tf.constant([2, 20, 30, 3, 6])
tf.math.argmax(A)  # A[2] is maximum in tensor A
<tf.Tensor: shape=(), dtype=int64, numpy=2>
B = tf.constant([[2, 20, 30, 3, 6], [3, 11, 16, 1, 8],
                 [14, 45, 23, 5, 27]])
tf.math.argmax(B, 0)
<tf.Tensor: shape=(5,), dtype=int64, numpy=array([2, 2, 0, 2, 2])>
tf.math.argmax(B, 1)
<tf.Tensor: shape=(3,), dtype=int64, numpy=array([2, 2, 1])>
C = tf.constant([0, 0, 0, 0])
tf.math.argmax(C) # Returns smallest index in case of ties
<tf.Tensor: shape=(), dtype=int64, numpy=0>

 Args
  input   A Tensor.
  axis   An integer, the axis to reduce across. Default to 0.
  output_type   An optional output dtype (tf.int32 or tf.int64). Defaults to tf.int64.
  name   An optional name for the operation.

 Returns   A Tensor of type output_type.


tf.math.argmin     View source on GitHub    Returns the index with the smallest value across axes of a tensor.  View aliases  Main aliases
tf.argmin
tf.math.argmin(
    input, axis=None, output_type=tf.dtypes.int64, name=None
)
 Returns the smallest index in case of ties.

 Args
  input   A 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.
  axis   A Tensor. Must be one of the following types: int32, int64. int32 or int64, must be in the range -rank(input), rank(input)). Describes which axis of the input Tensor to reduce across. For vectors, use axis = 0.
  output_type   An optional tf.DType from: tf.int32, tf.int64. Defaults to tf.int64.
  name   A name for the operation (optional).

 Returns   A Tensor of type output_type.
 Usage: import tensorflow as tf
a = [1, 10, 26.9, 2.8, 166.32, 62.3]
b = tf.math.argmin(input = a)
c = tf.keras.backend.eval(b)
# c = 0
# here a[0] = 1 which is the smallest element of a across axis 0


tf.math.asin Computes the trignometric inverse sine of x element-wise.  View aliases  Main aliases
tf.asin Compat aliases for migration See Migration guide for more details. tf.compat.v1.asin, tf.compat.v1.math.asin
tf.math.asin(
    x, name=None
)
 The tf.math.asin operation returns the inverse of tf.math.sin, such that if y = tf.math.sin(x) then, x = tf.math.asin(y).
Note: The output of tf.math.asin will lie within the invertible range of sine, i.e [-pi/2, pi/2].
 For example: # Note: [1.047, 0.785] ~= [(pi/3), (pi/4)]
x = tf.constant([1.047, 0.785])
y = tf.math.sin(x) # [0.8659266, 0.7068252]

tf.math.asin(y) # [1.047, 0.785] = x

 Args
  x   A Tensor. Must be one of the following types: bfloat16, half, float32, float64, int8, int16, int32, int64, complex64, complex128.
  name   A name for the operation (optional).

 Returns   A Tensor. Has the same type as x.


tf.math.asinh Computes inverse hyperbolic sine of x element-wise.  View aliases  Main aliases
tf.asinh Compat aliases for migration See Migration guide for more details. tf.compat.v1.asinh, tf.compat.v1.math.asinh
tf.math.asinh(
    x, name=None
)
 Given an input tensor, this function computes inverse hyperbolic sine for every element in the tensor. Both input and output has a range of [-inf, inf]. x = tf.constant([-float("inf"), -2, -0.5, 1, 1.2, 200, 10000, float("inf")])
tf.math.asinh(x) ==> [-inf -1.4436355 -0.4812118 0.8813736 1.0159732 5.991471 9.903487 inf]

 Args
  x   A Tensor. Must be one of the following types: bfloat16, half, float32, float64, complex64, complex128.
  name   A name for the operation (optional).

 Returns   A Tensor. Has the same type as x.


tf.math.atan Computes the trignometric inverse tangent of x element-wise.  View aliases  Main aliases
tf.atan Compat aliases for migration See Migration guide for more details. tf.compat.v1.atan, tf.compat.v1.math.atan
tf.math.atan(
    x, name=None
)
 The tf.math.atan operation returns the inverse of tf.math.tan, such that if y = tf.math.tan(x) then, x = tf.math.atan(y).
Note: The output of tf.math.atan will lie within the invertible range of tan, i.e (-pi/2, pi/2).
 For example: # Note: [1.047, 0.785] ~= [(pi/3), (pi/4)]
x = tf.constant([1.047, 0.785])
y = tf.math.tan(x) # [1.731261, 0.99920404]

tf.math.atan(y) # [1.047, 0.785] = x

 Args
  x   A Tensor. Must be one of the following types: bfloat16, half, float32, float64, int8, int16, int32, int64, complex64, complex128.
  name   A name for the operation (optional).

 Returns   A Tensor. Has the same type as x.


tf.math.atan2   Computes arctangent of y/x element-wise, respecting signs of the arguments.  View aliases  Main aliases
tf.atan2 Compat aliases for migration See Migration guide for more details. tf.compat.v1.atan2, tf.compat.v1.math.atan2
tf.math.atan2(
    y, x, name=None
)
 This is the angle ( \theta \in [-\pi, \pi] ) such that [ x = r \cos(\theta) ] and [ y = r \sin(\theta) ] where (r = \sqrt(x^2 + y^2) ).

 Args
  y   A Tensor. Must be one of the following types: bfloat16, half, float32, float64.
  x   A Tensor. Must have the same type as y.
  name   A name for the operation (optional).

 Returns   A Tensor. Has the same type as y.


tf.math.atanh Computes inverse hyperbolic tangent of x element-wise.  View aliases  Main aliases
tf.atanh Compat aliases for migration See Migration guide for more details. tf.compat.v1.atanh, tf.compat.v1.math.atanh
tf.math.atanh(
    x, name=None
)
 Given an input tensor, this function computes inverse hyperbolic tangent for every element in the tensor. Input range is [-1,1] and output range is [-inf, inf]. If input is -1, output will be -inf and if the input is 1, output will be inf. Values outside the range will have nan as output. x = tf.constant([-float("inf"), -1, -0.5, 1, 0, 0.5, 10, float("inf")])
tf.math.atanh(x) ==> [nan -inf -0.54930615 inf  0. 0.54930615 nan nan]

 Args
  x   A Tensor. Must be one of the following types: bfloat16, half, float32, float64, complex64, complex128.
  name   A name for the operation (optional).

 Returns   A Tensor. Has the same type as x.


tf.math.bessel_i0     View source on GitHub    Computes the Bessel i0 function of x element-wise.  View aliases  Main aliases
tf.math.special.bessel_i0 Compat aliases for migration See Migration guide for more details. tf.compat.v1.math.bessel_i0, tf.compat.v1.math.special.bessel_i0
tf.math.bessel_i0(
    x, name=None
)
 Modified Bessel function of order 0. It is preferable to use the numerically stabler function i0e(x) instead.
tf.math.special.bessel_i0([-1., -0.5, 0.5, 1.]).numpy()
array([1.26606588, 1.06348337, 1.06348337, 1.26606588], dtype=float32)

 Args
  x   A Tensor or SparseTensor. Must be one of the following types: half, float32, float64.
  name   A name for the operation (optional).

 Returns   A Tensor or SparseTensor, respectively. Has the same type as x.
 Scipy Compatibility Equivalent to scipy.special.i0


tf.math.bessel_i0e     View source on GitHub    Computes the Bessel i0e function of x element-wise.  View aliases  Main aliases
tf.math.special.bessel_i0e Compat aliases for migration See Migration guide for more details. tf.compat.v1.math.bessel_i0e, tf.compat.v1.math.special.bessel_i0e
tf.math.bessel_i0e(
    x, name=None
)
 Modified Bessel function of order 0.
tf.math.special.bessel_i0e([-1., -0.5, 0.5, 1.]).numpy()
array([0.46575961, 0.64503527, 0.64503527, 0.46575961], dtype=float32)

 Args
  x   A Tensor or SparseTensor. Must be one of the following types: half, float32, float64.
  name   A name for the operation (optional).

 Returns   A Tensor or SparseTensor, respectively. Has the same type as x. If x is a SparseTensor, returns SparseTensor(x.indices, tf.math.bessel_i0e(x.values, ...), x.dense_shape)

 Scipy Compatibility Equivalent to scipy.special.i0e


tf.math.bessel_i1     View source on GitHub    Computes the Bessel i1 function of x element-wise.  View aliases  Main aliases
tf.math.special.bessel_i1 Compat aliases for migration See Migration guide for more details. tf.compat.v1.math.bessel_i1, tf.compat.v1.math.special.bessel_i1
tf.math.bessel_i1(
    x, name=None
)
 Modified Bessel function of order 1. It is preferable to use the numerically stabler function i1e(x) instead.
tf.math.special.bessel_i1([-1., -0.5, 0.5, 1.]).numpy()
array([-0.5651591 , -0.25789431,  0.25789431,  0.5651591 ], dtype=float32)

 Args
  x   A Tensor or SparseTensor. Must be one of the following types: half, float32, float64.
  name   A name for the operation (optional).

 Returns   A Tensor or SparseTensor, respectively. Has the same type as x.
 Scipy Compatibility Equivalent to scipy.special.i1


tf.math.bessel_i1e     View source on GitHub    Computes the Bessel i1e function of x element-wise.  View aliases  Main aliases
tf.math.special.bessel_i1e Compat aliases for migration See Migration guide for more details. tf.compat.v1.math.bessel_i1e, tf.compat.v1.math.special.bessel_i1e
tf.math.bessel_i1e(
    x, name=None
)
 Modified Bessel function of order 1.
tf.math.special.bessel_i1e([-1., -0.5, 0.5, 1.]).numpy()
array([-0.20791042, -0.15642083,  0.15642083,  0.20791042], dtype=float32)

 Args
  x   A Tensor or SparseTensor. Must be one of the following types: half, float32, float64.
  name   A name for the operation (optional).

 Returns   A Tensor or SparseTensor, respectively. Has the same type as x. If x is a SparseTensor, returns SparseTensor(x.indices, tf.math.bessel_i1e(x.values, ...), x.dense_shape)

 Scipy Compatibility Equivalent to scipy.special.i1e


tf.math.betainc   Compute the regularized incomplete beta integral \(I_x(a, b)\).  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.betainc, tf.compat.v1.math.betainc
tf.math.betainc(
    a, b, x, name=None
)
 The regularized incomplete beta integral is defined as: \(I_x(a, b) = \frac{B(x; a, b)}{B(a, b)}\) where \(B(x; a, b) = \int_0^x t^{a-1} (1 - t)^{b-1} dt\) is the incomplete beta function and \(B(a, b)\) is the complete beta function.

 Args
  a   A Tensor. Must be one of the following types: float32, float64.
  b   A Tensor. Must have the same type as a.
  x   A Tensor. Must have the same type as a.
  name   A name for the operation (optional).

 Returns   A Tensor. Has the same type as a.


tf.math.bincount     View source on GitHub    Counts the number of occurrences of each value in an integer array.
tf.math.bincount(
    arr, weights=None, minlength=None, maxlength=None, dtype=tf.dtypes.int32,
    name=None, axis=None, binary_output=False
)
 If minlength and maxlength are not given, returns a vector with length tf.reduce_max(arr) + 1 if arr is non-empty, and length 0 otherwise. If weights are non-None, then index i of the output stores the sum of the value in weights at each index where the corresponding value in arr is i. values = tf.constant([1,1,2,3,2,4,4,5])
tf.math.bincount(values) #[0 2 2 1 2 1]
 Vector length = Maximum element in vector values is 5. Adding 1, which is 6 will be the vector length. Each bin value in the output indicates number of occurrences of the particular index. Here, index 1 in output has a value 2. This indicates value 1 occurs two times in values. values = tf.constant([1,1,2,3,2,4,4,5])
weights = tf.constant([1,5,0,1,0,5,4,5])
tf.math.bincount(values, weights=weights) #[0 6 0 1 9 5]
 Bin will be incremented by the corresponding weight instead of 1. Here, index 1 in output has a value 6. This is the summation of weights corresponding to the value in values. Bin-counting on a certain axis This example takes a 2 dimensional input and returns a Tensor with bincounting on each sample.
data = np.array([[1, 2, 3, 0], [0, 0, 1, 2]], dtype=np.int32)
tf.math.bincount(data, axis=-1)
<tf.Tensor: shape=(2, 4), dtype=int32, numpy=
  array([[1, 1, 1, 1],
         [2, 1, 1, 0]], dtype=int32)>
 Bin-counting with binary_output This example gives binary output instead of counting the occurrence.
data = np.array([[1, 2, 3, 0], [0, 0, 1, 2]], dtype=np.int32)
tf.math.bincount(data, axis=-1, binary_output=True)
<tf.Tensor: shape=(2, 4), dtype=int32, numpy=
  array([[1, 1, 1, 1],
         [1, 1, 1, 0]], dtype=int32)>

 Args
  arr   A Tensor, RaggedTensor, or SparseTensor whose values should be counted. These tensors must have a rank of 2 if axis=-1.
  weights   If non-None, must be the same shape as arr. For each value in arr, the bin will be incremented by the corresponding weight instead of 1.
  minlength   If given, ensures the output has length at least minlength, padding with zeros at the end if necessary.
  maxlength   If given, skips values in arr that are equal or greater than maxlength, ensuring that the output has length at most maxlength.
  dtype   If weights is None, determines the type of the output bins.
  name   A name scope for the associated operations (optional).
  axis   The axis to slice over. Axes at and below axis will be flattened before bin counting. Currently, only 0, and -1 are supported. If None, all axes will be flattened (identical to passing 0).
  binary_output   If True, this op will output 1 instead of the number of times a token appears (equivalent to one_hot + reduce_any instead of one_hot + reduce_add). Defaults to False.

 Returns   A vector with the same dtype as weights or the given dtype. The bin values.

 Raises   InvalidArgumentError if negative values are provided as an input.


tf.math.ceil     View source on GitHub    Return the ceiling of the input, element-wise.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.ceil, tf.compat.v1.math.ceil
tf.math.ceil(
    x, name=None
)
 For example:
tf.math.ceil([-1.7, -1.5, -0.2, 0.2, 1.5, 1.7, 2.0])
<tf.Tensor: shape=(7,), dtype=float32,
numpy=array([-1., -1., -0.,  1.,  2.,  2.,  2.], dtype=float32)>

 Args
  x   A tf.Tensor. Must be one of the following types: bfloat16, half, float32, float64. int32
  name   A name for the operation (optional).

 Returns   A tf.Tensor. Has the same type as x.
 Numpy Compatibility Equivalent to np.ceil


tf.math.confusion_matrix     View source on GitHub    Computes the confusion matrix from predictions and labels.
tf.math.confusion_matrix(
    labels, predictions, num_classes=None, weights=None, dtype=tf.dtypes.int32,
    name=None
)
 The matrix columns represent the prediction labels and the rows represent the real labels. The confusion matrix is always a 2-D array of shape [n, n], where n is the number of valid labels for a given classification task. Both prediction and labels must be 1-D arrays of the same shape in order for this function to work. If num_classes is None, then num_classes will be set to one plus the maximum value in either predictions or labels. Class labels are expected to start at 0. For example, if num_classes is 3, then the possible labels would be [0, 1, 2]. If weights is not None, then each prediction contributes its corresponding weight to the total value of the confusion matrix cell. For example: tf.math.confusion_matrix([1, 2, 4], [2, 2, 4]) ==>
    [[0 0 0 0 0]
     [0 0 1 0 0]
     [0 0 1 0 0]
     [0 0 0 0 0]
     [0 0 0 0 1]]
 Note that the possible labels are assumed to be [0, 1, 2, 3, 4], resulting in a 5x5 confusion matrix.

 Args
  labels   1-D Tensor of real labels for the classification task.
  predictions   1-D Tensor of predictions for a given classification.
  num_classes   The possible number of labels the classification task can have. If this value is not provided, it will be calculated using both predictions and labels array.
  weights   An optional Tensor whose shape matches predictions.
  dtype   Data type of the confusion matrix.
  name   Scope name.

 Returns   A Tensor of type dtype with shape [n, n] representing the confusion matrix, where n is the number of possible labels in the classification task.

 Raises
  ValueError   If both predictions and labels are not 1-D vectors and have mismatched shapes, or if weights is not None and its shape doesn't match predictions.


tf.math.conj       View source on GitHub    Returns the complex conjugate of a complex number.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.conj, tf.compat.v1.math.conj
tf.math.conj(
    x, name=None
)
 Given a tensor x of complex numbers, this operation returns a tensor of complex numbers that are the complex conjugate of each element in x. The complex numbers in x must be of the form \(a + bj\), where a is the real part and b is the imaginary part. The complex conjugate returned by this operation is of the form \(a - bj\). For example:
x = tf.constant([-2.25 + 4.75j, 3.25 + 5.75j])
tf.math.conj(x)
<tf.Tensor: shape=(2,), dtype=complex128,
numpy=array([-2.25-4.75j,  3.25-5.75j])>
 If x is real, it is returned unchanged. For example:
x = tf.constant([-2.25, 3.25])
tf.math.conj(x)
<tf.Tensor: shape=(2,), dtype=float32,
numpy=array([-2.25,  3.25], dtype=float32)>

 Args
  x   Tensor to conjugate. Must have numeric or variant type.
  name   A name for the operation (optional).

 Returns   A Tensor that is the conjugate of x (with the same type).

 Raises
  TypeError   If x is not a numeric tensor.    Numpy Compatibility Equivalent to numpy.conj.


tf.math.cos Computes cos of x element-wise.  View aliases  Main aliases
tf.cos Compat aliases for migration See Migration guide for more details. tf.compat.v1.cos, tf.compat.v1.math.cos
tf.math.cos(
    x, name=None
)
 Given an input tensor, this function computes cosine of every element in the tensor. Input range is (-inf, inf) and output range is [-1,1]. If input lies outside the boundary, nan is returned. x = tf.constant([-float("inf"), -9, -0.5, 1, 1.2, 200, 10000, float("inf")])
tf.math.cos(x) ==> [nan -0.91113025 0.87758255 0.5403023 0.36235774 0.48718765 -0.95215535 nan]

 Args
  x   A Tensor. Must be one of the following types: bfloat16, half, float32, float64, complex64, complex128.
  name   A name for the operation (optional).

 Returns   A Tensor. Has the same type as x.


tf.math.cosh Computes hyperbolic cosine of x element-wise.  View aliases  Main aliases
tf.cosh Compat aliases for migration See Migration guide for more details. tf.compat.v1.cosh, tf.compat.v1.math.cosh
tf.math.cosh(
    x, name=None
)
 Given an input tensor, this function computes hyperbolic cosine of every element in the tensor. Input range is [-inf, inf] and output range is [1, inf]. x = tf.constant([-float("inf"), -9, -0.5, 1, 1.2, 2, 10, float("inf")])
tf.math.cosh(x) ==> [inf 4.0515420e+03 1.1276259e+00 1.5430807e+00 1.8106556e+00 3.7621956e+00 1.1013233e+04 inf]

 Args
  x   A Tensor. Must be one of the following types: bfloat16, half, float32, float64, complex64, complex128.
  name   A name for the operation (optional).

 Returns   A Tensor. Has the same type as x.


tf.math.count_nonzero     View source on GitHub    Computes number of nonzero elements across dimensions of a tensor.
tf.math.count_nonzero(
    input, axis=None, keepdims=None, dtype=tf.dtypes.int64, name=None
)
 Reduces input along the dimensions given in axis. Unless keepdims is true, the rank of the tensor is reduced by 1 for each entry in axis. 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.
Note: Floating point comparison to zero is done by exact floating point equality check. Small values are not rounded to zero for purposes of the nonzero check.
 For example: x = tf.constant([[0, 1, 0], [1, 1, 0]])
tf.math.count_nonzero(x)  # 3
tf.math.count_nonzero(x, 0)  # [1, 2, 0]
tf.math.count_nonzero(x, 1)  # [1, 2]
tf.math.count_nonzero(x, 1, keepdims=True)  # [[1], [2]]
tf.math.count_nonzero(x, [0, 1])  # 3

Note: Strings are compared against zero-length empty string "". Any string with a size greater than zero is already considered as nonzero.
 For example: x = tf.constant(["", "a", "  ", "b", ""])
tf.math.count_nonzero(x) # 3, with "a", "  ", and "b" as nonzero strings.

 Args
  input   The tensor to reduce. Should be of numeric type, bool, or string.
  axis   The dimensions to reduce. If None (the default), reduces all dimensions. Must be in the range [-rank(input), rank(input)).
  keepdims   If true, retains reduced dimensions with length 1.
  dtype   The output dtype; defaults to tf.int64.
  name   A name for the operation (optional).

 Returns   The reduced tensor (number of nonzero values).


tf.math.cumprod     View source on GitHub    Compute the cumulative product of the tensor x along axis.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.cumprod, tf.compat.v1.math.cumprod
tf.math.cumprod(
    x, axis=0, exclusive=False, reverse=False, name=None
)
 By default, this op performs an inclusive cumprod, which means that the first element of the input is identical to the first element of the output: tf.math.cumprod([a, b, c])  # [a, a * b, a * b * c]
 By setting the exclusive kwarg to True, an exclusive cumprod is performed instead: tf.math.cumprod([a, b, c], exclusive=True)  # [1, a, a * b]
 By setting the reverse kwarg to True, the cumprod is performed in the opposite direction: tf.math.cumprod([a, b, c], reverse=True)  # [a * b * c, b * c, c]
 This is more efficient than using separate tf.reverse ops. The reverse and exclusive kwargs can also be combined: tf.math.cumprod([a, b, c], exclusive=True, reverse=True)  # [b * c, c, 1]

 Args
  x   A Tensor. Must be one of the following types: float32, float64, int64, int32, uint8, uint16, int16, int8, complex64, complex128, qint8, quint8, qint32, half.
  axis   A Tensor of type int32 (default: 0). Must be in the range [-rank(x), rank(x)).
  exclusive   If True, perform exclusive cumprod.
  reverse   A bool (default: False).
  name   A name for the operation (optional).

 Returns   A Tensor. Has the same type as x.


tf.math.cumsum     View source on GitHub    Compute the cumulative sum of the tensor x along axis.  View aliases  Main aliases
tf.cumsum Compat aliases for migration See Migration guide for more details. tf.compat.v1.cumsum, tf.compat.v1.math.cumsum
tf.math.cumsum(
    x, axis=0, exclusive=False, reverse=False, name=None
)
 By default, this op performs an inclusive cumsum, which means that the first element of the input is identical to the first element of the output: For example:
# tf.cumsum([a, b, c])   # [a, a + b, a + b + c]
x = tf.constant([2, 4, 6, 8])
tf.cumsum(x)
<tf.Tensor: shape=(4,), dtype=int32,
numpy=array([ 2,  6, 12, 20], dtype=int32)>

# using varying `axis` values
y = tf.constant([[2, 4, 6, 8], [1,3,5,7]])
tf.cumsum(y, axis=0)
<tf.Tensor: shape=(2, 4), dtype=int32, numpy=
array([[ 2,  4,  6,  8],
       [ 3,  7, 11, 15]], dtype=int32)>
tf.cumsum(y, axis=1)
<tf.Tensor: shape=(2, 4), dtype=int32, numpy=
array([[ 2,  6, 12, 20],
       [ 1,  4,  9, 16]], dtype=int32)>
 By setting the exclusive kwarg to True, an exclusive cumsum is performed instead:
# tf.cumsum([a, b, c], exclusive=True)  => [0, a, a + b]
x = tf.constant([2, 4, 6, 8])
tf.cumsum(x, exclusive=True)
<tf.Tensor: shape=(4,), dtype=int32,
numpy=array([ 0,  2,  6, 12], dtype=int32)>
 By setting the reverse kwarg to True, the cumsum is performed in the opposite direction:
# tf.cumsum([a, b, c], reverse=True)  # [a + b + c, b + c, c]
x = tf.constant([2, 4, 6, 8])
tf.cumsum(x, reverse=True)
<tf.Tensor: shape=(4,), dtype=int32,
numpy=array([20, 18, 14,  8], dtype=int32)>
 This is more efficient than using separate tf.reverse ops. The reverse and exclusive kwargs can also be combined:
# tf.cumsum([a, b, c], exclusive=True, reverse=True)  # [b + c, c, 0]
x = tf.constant([2, 4, 6, 8])
tf.cumsum(x, exclusive=True, reverse=True)
<tf.Tensor: shape=(4,), dtype=int32,
numpy=array([18, 14,  8,  0], dtype=int32)>

 Args
  x   A Tensor. Must be one of the following types: float32, float64, int64, int32, uint8, uint16, int16, int8, complex64, complex128, qint8, quint8, qint32, half.
  axis   A Tensor of type int32 (default: 0). Must be in the range [-rank(x), rank(x)).
  exclusive   If True, perform exclusive cumsum.
  reverse   A bool (default: False).
  name   A name for the operation (optional).

 Returns   A Tensor. Has the same type as x.


tf.math.cumulative_logsumexp     View source on GitHub    Compute the cumulative log-sum-exp of the tensor x along axis.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.math.cumulative_logsumexp
tf.math.cumulative_logsumexp(
    x, axis=0, exclusive=False, reverse=False, name=None
)
 By default, this op performs an inclusive cumulative log-sum-exp, which means that the first element of the input is identical to the first element of the output. This operation is significantly more numerically stable than the equivalent tensorflow operation tf.math.log(tf.math.cumsum(tf.math.exp(x))), although computes the same result given infinite numerical precision. However, note that in some cases, it may be less stable than tf.math.reduce_logsumexp for a given element, as it applies the "log-sum-exp trick" in a different way. More precisely, where tf.math.reduce_logsumexp uses the following trick: log(sum(exp(x))) == log(sum(exp(x - max(x)))) + max(x)
 it cannot be directly used here as there is no fast way of applying it to each prefix x[:i]. Instead, this function implements a prefix scan using pairwise log-add-exp, which is a commutative and associative (up to floating point precision) operator: log_add_exp(x, y) = log(exp(x) + exp(y))
                  = log(1 + exp(min(x, y) - max(x, y))) + max(x, y)
 However, reducing using the above operator leads to a different computation tree (logs are taken repeatedly instead of only at the end), and the maximum is only computed pairwise instead of over the entire prefix. In general, this leads to a different and slightly less precise computation.

 Args
  x   A Tensor. Must be one of the following types: float16, float32, float64.
  axis   A Tensor of type int32 or int64 (default: 0). Must be in the range [-rank(x), rank(x)).
  exclusive   If True, perform exclusive cumulative log-sum-exp.
  reverse   If True, performs the cumulative log-sum-exp in the reverse direction.
  name   A name for the operation (optional).

 Returns   A Tensor. Has the same shape and type as x.


tf.math.digamma Computes Psi, the derivative of Lgamma (the log of the absolute value of  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.digamma, tf.compat.v1.math.digamma
tf.math.digamma(
    x, name=None
)
 Gamma(x)), element-wise.

 Args
  x   A Tensor. Must be one of the following types: bfloat16, half, float32, float64.
  name   A name for the operation (optional).

 Returns   A Tensor. Has the same type as x.


tf.math.divide     View source on GitHub    Computes Python style division of x by y.  View aliases  Main aliases
tf.divide Compat aliases for migration See Migration guide for more details. tf.compat.v1.divide, tf.compat.v1.math.divide
tf.math.divide(
    x, y, name=None
)
 For example:
x = tf.constant([16, 12, 11])
y = tf.constant([4, 6, 2])
tf.divide(x,y)
<tf.Tensor: shape=(3,), dtype=float64,
numpy=array([4. , 2. , 5.5])>

 Args
  x   A Tensor
  y   A Tensor
  name   A name for the operation (optional).

 Returns   A Tensor with same shape as input


tf.math.divide_no_nan     View source on GitHub    Computes a safe divide which returns 0 if the y is zero.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.div_no_nan, tf.compat.v1.math.divide_no_nan
tf.math.divide_no_nan(
    x, y, name=None
)

 Args
  x   A Tensor. Must be one of the following types: float32, float64.
  y   A Tensor whose dtype is compatible with x.
  name   A name for the operation (optional).

 Returns   The element-wise value of the x divided by y.


tf.math.equal     View source on GitHub    Returns the truth value of (x == y) element-wise.  View aliases  Main aliases
tf.equal Compat aliases for migration See Migration guide for more details. tf.compat.v1.equal, tf.compat.v1.math.equal
tf.math.equal(
    x, y, name=None
)
 Performs a broadcast with the arguments and then an element-wise equality comparison, returning a Tensor of boolean values. For example:
x = tf.constant([2, 4])
y = tf.constant(2)
tf.math.equal(x, y)
<tf.Tensor: shape=(2,), dtype=bool, numpy=array([ True,  False])>

x = tf.constant([2, 4])
y = tf.constant([2, 4])
tf.math.equal(x, y)
<tf.Tensor: shape=(2,), dtype=bool, numpy=array([ True,  True])>

 Args
  x   A tf.Tensor or tf.sparse.SparseTensor or tf.IndexedSlices.
  y   A tf.Tensor or tf.sparse.SparseTensor or tf.IndexedSlices.
  name   A name for the operation (optional).

 Returns   A tf.Tensor of type bool with the same size as that of x or y.

 Raises   tf.errors.InvalidArgumentError: If shapes of arguments are incompatible


tf.math.erf Computes the Gauss error function of x element-wise.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.erf, tf.compat.v1.math.erf
tf.math.erf(
    x, name=None
)

 Args
  x   A Tensor. Must be one of the following types: bfloat16, half, float32, float64.
  name   A name for the operation (optional).

 Returns   A Tensor. Has the same type as x. If x is a SparseTensor, returns SparseTensor(x.indices, tf.math.erf(x.values, ...), x.dense_shape)


tf.math.erfc Computes the complementary error function of x element-wise.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.erfc, tf.compat.v1.math.erfc
tf.math.erfc(
    x, name=None
)

 Args
  x   A Tensor. Must be one of the following types: bfloat16, half, float32, float64.
  name   A name for the operation (optional).

 Returns   A Tensor. Has the same type as x.


tf.math.erfcinv Computes the inverse of complementary error function.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.math.erfcinv
tf.math.erfcinv(
    x, name=None
)
 Given x, compute the inverse complementary error function of x. This function is the inverse of tf.math.erfc, and is defined on [0, 2].
tf.math.erfcinv([0., 0.2, 1., 1.5, 2.])
<tf.Tensor: shape=(5,), dtype=float32, numpy=
array([       inf,  0.9061935, -0.       , -0.4769363,       -inf],
      dtype=float32)>

 Args
  x   Tensor with type float or double.
  name   A name for the operation (optional).

 Returns   Inverse complementary error function of x.
 Numpy Compatibility Equivalent to scipy.special.erfcinv


tf.math.erfinv Compute inverse error function.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.math.erfinv
tf.math.erfinv(
    x, name=None
)
 Given x, compute the inverse error function of x. This function is the inverse of tf.math.erf.

 Args
  x   Tensor with type float or double.
  name   A name for the operation (optional).

 Returns   Inverse error function of x.


tf.math.exp       View source on GitHub    Computes exponential of x element-wise. \(y = e^x\).  View aliases  Main aliases
tf.exp Compat aliases for migration See Migration guide for more details. tf.compat.v1.exp, tf.compat.v1.math.exp
tf.math.exp(
    x, name=None
)
 This function computes the exponential of the input tensor element-wise. i.e. math.exp(x) or \(e^x\), where x is the input tensor. \(e\) denotes Euler's number and is approximately equal to 2.718281. Output is positive for any real input.
x = tf.constant(2.0)
tf.math.exp(x)
<tf.Tensor: shape=(), dtype=float32, numpy=7.389056>

x = tf.constant([2.0, 8.0])
tf.math.exp(x)
<tf.Tensor: shape=(2,), dtype=float32,
numpy=array([   7.389056, 2980.958   ], dtype=float32)>
 For complex numbers, the exponential value is calculated as  $$ e^{x+iy} = {e^x} {e^{iy} } = {e^x} ({\cos (y) + i \sin (y)}) $$  For 1+1j the value would be computed as:  $$ e^1 (\cos (1) + i \sin (1)) = 2.7182817 \times (0.5403023+0.84147096j) $$
x = tf.constant(1 + 1j)
tf.math.exp(x)
<tf.Tensor: shape=(), dtype=complex128,
numpy=(1.4686939399158851+2.2873552871788423j)>

 Args
  x   A tf.Tensor. Must be one of the following types: bfloat16, half, float32, float64, complex64, complex128.
  name   A name for the operation (optional).

 Returns   A tf.Tensor. Has the same type as x.
 Numpy Compatibility Equivalent to np.exp


tf.math.expm1 Computes exp(x) - 1 element-wise.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.expm1, tf.compat.v1.math.expm1
tf.math.expm1(
    x, name=None
)
 i.e. exp(x) - 1 or e^(x) - 1, where x is the input tensor. e denotes Euler's number and is approximately equal to 2.718281. x = tf.constant(2.0)
tf.math.expm1(x) ==> 6.389056

x = tf.constant([2.0, 8.0])
tf.math.expm1(x) ==> array([6.389056, 2979.958], dtype=float32)

x = tf.constant(1 + 1j)
tf.math.expm1(x) ==> (0.46869393991588515+2.2873552871788423j)

 Args
  x   A Tensor. Must be one of the following types: bfloat16, half, float32, float64, complex64, complex128.
  name   A name for the operation (optional).

 Returns   A Tensor. Has the same type as x.


tf.math.floor     View source on GitHub    Returns element-wise largest integer not greater than x.  View aliases  Main aliases
tf.floor Compat aliases for migration See Migration guide for more details. tf.compat.v1.floor, tf.compat.v1.math.floor
tf.math.floor(
    x, name=None
)
 Both input range is (-inf, inf) and the ouput range consists of all integer values. For example:
x = tf.constant([1.3324, -1.5, 5.555, -2.532, 0.99, float("inf")])
tf.floor(x).numpy()
array([ 1., -2.,  5., -3.,  0., inf], dtype=float32)

 Args
  x   A Tensor. Must be one of the following types: bfloat16, half, float32, float64.
  name   A name for the operation (optional).

 Returns   A Tensor. Has the same type as x.


tf.math.floordiv     View source on GitHub    Divides x / y elementwise, rounding toward the most negative integer.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.floordiv, tf.compat.v1.math.floordiv
tf.math.floordiv(
    x, y, name=None
)
 The same as tf.compat.v1.div(x,y) for integers, but uses tf.floor(tf.compat.v1.div(x,y)) for floating point arguments so that the result is always an integer (though possibly an integer represented as floating point). This op is generated by x // y floor division in Python 3 and in Python 2.7 with from __future__ import division. x and y must have the same type, and the result will have the same type as well.

 Args
  x   Tensor numerator of real numeric type.
  y   Tensor denominator of real numeric type.
  name   A name for the operation (optional).

 Returns   x / y rounded down.

 Raises
  TypeError   If the inputs are complex.


tf.math.floormod Returns element-wise remainder of division. When x < 0 xor y < 0 is  View aliases  Main aliases
tf.math.mod Compat aliases for migration See Migration guide for more details. tf.compat.v1.floormod, tf.compat.v1.math.floormod, tf.compat.v1.math.mod, tf.compat.v1.mod
tf.math.floormod(
    x, y, name=None
)
 true, this follows Python semantics in that the result here is consistent with a flooring divide. E.g. floor(x / y) * y + mod(x, y) = x.
Note: math.floormod supports broadcasting. More about broadcasting here

 Args
  x   A Tensor. Must be one of the following types: int32, int64, uint64, bfloat16, half, float32, float64.
  y   A Tensor. Must have the same type as x.
  name   A name for the operation (optional).

 Returns   A Tensor. Has the same type as x.


tf.math.greater Returns the truth value of (x > y) element-wise.  View aliases  Main aliases
tf.greater Compat aliases for migration See Migration guide for more details. tf.compat.v1.greater, tf.compat.v1.math.greater
tf.math.greater(
    x, y, name=None
)

Note: math.greater supports broadcasting. More about broadcasting here
 Example: x = tf.constant([5, 4, 6])
y = tf.constant([5, 2, 5])
tf.math.greater(x, y) ==> [False, True, True]

x = tf.constant([5, 4, 6])
y = tf.constant([5])
tf.math.greater(x, y) ==> [False, False, True]

 Args
  x   A Tensor. Must be one of the following types: float32, float64, int32, uint8, int16, int8, int64, bfloat16, uint16, half, uint32, uint64.
  y   A Tensor. Must have the same type as x.
  name   A name for the operation (optional).

 Returns   A Tensor of type bool.


tf.math.greater_equal Returns the truth value of (x >= y) element-wise.  View aliases  Main aliases
tf.greater_equal Compat aliases for migration See Migration guide for more details. tf.compat.v1.greater_equal, tf.compat.v1.math.greater_equal
tf.math.greater_equal(
    x, y, name=None
)

Note: math.greater_equal supports broadcasting. More about broadcasting here
 Example: x = tf.constant([5, 4, 6, 7])
y = tf.constant([5, 2, 5, 10])
tf.math.greater_equal(x, y) ==> [True, True, True, False]

x = tf.constant([5, 4, 6, 7])
y = tf.constant([5])
tf.math.greater_equal(x, y) ==> [True, False, True, True]

 Args
  x   A Tensor. Must be one of the following types: float32, float64, int32, uint8, int16, int8, int64, bfloat16, uint16, half, uint32, uint64.
  y   A Tensor. Must have the same type as x.
  name   A name for the operation (optional).

 Returns   A Tensor of type bool.


tf.math.igamma   Compute the lower regularized incomplete Gamma function P(a, x).  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.igamma, tf.compat.v1.math.igamma
tf.math.igamma(
    a, x, name=None
)
 The lower regularized incomplete Gamma function is defined as: \(P(a, x) = gamma(a, x) / Gamma(a) = 1 - Q(a, x)\) where \(gamma(a, x) = \\int_{0}^{x} t^{a-1} exp(-t) dt\) is the lower incomplete Gamma function. Note, above Q(a, x) (Igammac) is the upper regularized complete Gamma function.

 Args
  a   A Tensor. Must be one of the following types: float32, float64.
  x   A Tensor. Must have the same type as a.
  name   A name for the operation (optional).

 Returns   A Tensor. Has the same type as a.


tf.math.igammac   Compute the upper regularized incomplete Gamma function Q(a, x).  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.igammac, tf.compat.v1.math.igammac
tf.math.igammac(
    a, x, name=None
)
 The upper regularized incomplete Gamma function is defined as: \(Q(a, x) = Gamma(a, x) / Gamma(a) = 1 - P(a, x)\) where \(Gamma(a, x) = int_{x}^{\infty} t^{a-1} exp(-t) dt\) is the upper incomplete Gama function. Note, above P(a, x) (Igamma) is the lower regularized complete Gamma function.

 Args
  a   A Tensor. Must be one of the following types: float32, float64.
  x   A Tensor. Must have the same type as a.
  name   A name for the operation (optional).

 Returns   A Tensor. Has the same type as a.


tf.math.imag     View source on GitHub    Returns the imaginary part of a complex (or real) tensor.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.imag, tf.compat.v1.math.imag
tf.math.imag(
    input, name=None
)
 Given a tensor input, this operation returns a tensor of type float that is the imaginary part of each element in input considered as a complex number. If input is real, a tensor of all zeros is returned. For example: x = tf.constant([-2.25 + 4.75j, 3.25 + 5.75j])
tf.math.imag(x)  # [4.75, 5.75]

 Args
  input   A Tensor. Must be one of the following types: float, double, complex64, complex128.
  name   A name for the operation (optional).

 Returns   A Tensor of type float32 or float64.


tf.math.invert_permutation Computes the inverse permutation of a tensor.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.invert_permutation, tf.compat.v1.math.invert_permutation
tf.math.invert_permutation(
    x, name=None
)
 This operation computes the inverse of an index permutation. It takes a 1-D integer tensor x, which represents the indices of a zero-based array, and swaps each value with its index position. In other words, for an output tensor y and an input tensor x, this operation computes the following: y[x[i]] = i for i in [0, 1, ..., len(x) - 1] The values must include 0. There can be no duplicate values or negative values. For example: # tensor `x` is [3, 4, 0, 2, 1]
invert_permutation(x) ==> [2, 4, 3, 0, 1]

 Args
  x   A Tensor. Must be one of the following types: int32, int64. 1-D.
  name   A name for the operation (optional).

 Returns   A Tensor. Has the same type as x.


tf.math.in_top_k       View source on GitHub    Says whether the targets are in the top K predictions.  View aliases  Main aliases
tf.nn.in_top_k
tf.math.in_top_k(
    targets, predictions, k, name=None
)
 This outputs a batch_size bool array, an entry out[i] is true if the prediction for the target class is finite (not inf, -inf, or nan) and among the top k predictions among all predictions for example i. Note that the behavior of InTopK differs from the TopK op in its handling of ties; if multiple classes have the same prediction value and straddle the top-k boundary, all of those classes are considered to be in the top k. More formally, let \(predictions_i\) be the predictions for all classes for example i, \(targets_i\) be the target class for example i, \(out_i\) be the output for example i,  $$out_i = predictions_{i, targets_i} \in TopKIncludingTies(predictions_i)$$

 Args
  predictions   A Tensor of type float32. A batch_size x classes tensor.
  targets   A Tensor. Must be one of the following types: int32, int64. A batch_size vector of class ids.
  k   An int. Number of top elements to look at for computing precision.
  name   A name for the operation (optional).

 Returns   A Tensor of type bool. Computed Precision at k as a bool Tensor.


tf.math.is_finite Returns which elements of x are finite.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.debugging.is_finite, tf.compat.v1.is_finite, tf.compat.v1.math.is_finite
tf.math.is_finite(
    x, name=None
)
 Example: x = tf.constant([5.0, 4.8, 6.8, np.inf, np.nan])
tf.math.is_finite(x) ==> [True, True, True, False, False]

 Args
  x   A Tensor. Must be one of the following types: bfloat16, half, float32, float64.
  name   A name for the operation (optional).

 Returns   A Tensor of type bool.
 Numpy Compatibility Equivalent to np.isfinite


tf.math.is_inf Returns which elements of x are Inf.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.debugging.is_inf, tf.compat.v1.is_inf, tf.compat.v1.math.is_inf
tf.math.is_inf(
    x, name=None
)
 Example: x = tf.constant([5.0, np.inf, 6.8, np.inf])
tf.math.is_inf(x) ==> [False, True, False, True]

 Args
  x   A Tensor. Must be one of the following types: bfloat16, half, float32, float64.
  name   A name for the operation (optional).

 Returns   A Tensor of type bool.
 Numpy Compatibility Equivalent to np.isinf


tf.math.is_nan Returns which elements of x are NaN.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.debugging.is_nan, tf.compat.v1.is_nan, tf.compat.v1.math.is_nan
tf.math.is_nan(
    x, name=None
)
 Example: x = tf.constant([5.0, np.nan, 6.8, np.nan, np.inf])
tf.math.is_nan(x) ==> [False, True, False, True, False]

 Args
  x   A Tensor. Must be one of the following types: bfloat16, half, float32, float64.
  name   A name for the operation (optional).

 Returns   A Tensor of type bool.
 Numpy Compatibility Equivalent to np.isnan


tf.math.is_non_decreasing     View source on GitHub    Returns True if x is non-decreasing.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.debugging.is_non_decreasing, tf.compat.v1.is_non_decreasing, tf.compat.v1.math.is_non_decreasing
tf.math.is_non_decreasing(
    x, name=None
)
 Elements of x are compared in row-major order. The tensor [x[0],...] is non-decreasing if for every adjacent pair we have x[i] <= x[i+1]. If x has less than two elements, it is trivially non-decreasing. See also: is_strictly_increasing
x1 = tf.constant([1.0, 1.0, 3.0])
tf.math.is_non_decreasing(x1)
<tf.Tensor: shape=(), dtype=bool, numpy=True>
x2 = tf.constant([3.0, 1.0, 2.0])
tf.math.is_non_decreasing(x2)
<tf.Tensor: shape=(), dtype=bool, numpy=False>

 Args
  x   Numeric Tensor.
  name   A name for this operation (optional). Defaults to "is_non_decreasing"

 Returns   Boolean Tensor, equal to True iff x is non-decreasing.

 Raises
  TypeError   if x is not a numeric tensor.


tf.math.is_strictly_increasing     View source on GitHub    Returns True if x is strictly increasing.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.debugging.is_strictly_increasing, tf.compat.v1.is_strictly_increasing, tf.compat.v1.math.is_strictly_increasing
tf.math.is_strictly_increasing(
    x, name=None
)
 Elements of x are compared in row-major order. The tensor [x[0],...] is strictly increasing if for every adjacent pair we have x[i] < x[i+1]. If x has less than two elements, it is trivially strictly increasing. See also: is_non_decreasing
x1 = tf.constant([1.0, 2.0, 3.0])
tf.math.is_strictly_increasing(x1)
<tf.Tensor: shape=(), dtype=bool, numpy=True>
x2 = tf.constant([3.0, 1.0, 2.0])
tf.math.is_strictly_increasing(x2)
<tf.Tensor: shape=(), dtype=bool, numpy=False>

 Args
  x   Numeric Tensor.
  name   A name for this operation (optional). Defaults to "is_strictly_increasing"

 Returns   Boolean Tensor, equal to True iff x is strictly increasing.

 Raises
  TypeError   if x is not a numeric tensor.


tf.math.l2_normalize     View source on GitHub    Normalizes along dimension axis using an L2 norm.  View aliases  Main aliases
tf.linalg.l2_normalize, tf.nn.l2_normalize
tf.math.l2_normalize(
    x, axis=None, epsilon=1e-12, name=None
)
 For a 1-D tensor with axis = 0, computes output = x / sqrt(max(sum(x**2), epsilon))
 For x with more dimensions, independently normalizes each 1-D slice along dimension axis.

 Args
  x   A Tensor.
  axis   Dimension along which to normalize. A scalar or a vector of integers.
  epsilon   A lower bound value for the norm. Will use sqrt(epsilon) as the divisor if norm < sqrt(epsilon).
  name   A name for this operation (optional).

 Returns   A Tensor with the same shape as x.


tf.math.lbeta       View source on GitHub    Computes \(ln(|Beta(x)|)\), reducing along the last dimension.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.lbeta, tf.compat.v1.math.lbeta
tf.math.lbeta(
    x, name=None
)
 Given one-dimensional $z = [z_1,...,z_K]$, we define  $$Beta(z) = \frac{\prod_j \Gamma(z_j)}{\Gamma(\sum_j z_j)},$$  where $\Gamma$ is the gamma function. And for $n + 1$ dimensional $x$ with shape $[N_1, ..., N_n, K]$, we define  $$lbeta(x)[i_1, ..., i_n] = \log{|Beta(x[i_1, ..., i_n, :])|}.$$  In other words, the last dimension is treated as the $z$ vector. Note that if $z = [u, v]$, then  $$Beta(z) = \frac{\Gamma(u)\Gamma(v)}{\Gamma(u + v)} = \int_0^1 t^{u-1} (1 - t)^{v-1} \mathrm{d}t,$$  which defines the traditional bivariate beta function. If the last dimension is empty, we follow the convention that the sum over the empty set is zero, and the product is one.

 Args
  x   A rank n + 1 Tensor, n >= 0 with type float, or double.
  name   A name for the operation (optional).

 Returns   The logarithm of \(|Beta(x)|\) reducing along the last dimension.


tf.math.less Returns the truth value of (x < y) element-wise.  View aliases  Main aliases
tf.less Compat aliases for migration See Migration guide for more details. tf.compat.v1.less, tf.compat.v1.math.less
tf.math.less(
    x, y, name=None
)

Note: math.less supports broadcasting. More about broadcasting here
 Example: x = tf.constant([5, 4, 6])
y = tf.constant([5])
tf.math.less(x, y) ==> [False, True, False]

x = tf.constant([5, 4, 6])
y = tf.constant([5, 6, 7])
tf.math.less(x, y) ==> [False, True, True]

 Args
  x   A Tensor. Must be one of the following types: float32, float64, int32, uint8, int16, int8, int64, bfloat16, uint16, half, uint32, uint64.
  y   A Tensor. Must have the same type as x.
  name   A name for the operation (optional).

 Returns   A Tensor of type bool.


tf.math.less_equal Returns the truth value of (x <= y) element-wise.  View aliases  Main aliases
tf.less_equal Compat aliases for migration See Migration guide for more details. tf.compat.v1.less_equal, tf.compat.v1.math.less_equal
tf.math.less_equal(
    x, y, name=None
)

Note: math.less_equal supports broadcasting. More about broadcasting here
 Example: x = tf.constant([5, 4, 6])
y = tf.constant([5])
tf.math.less_equal(x, y) ==> [True, True, False]

x = tf.constant([5, 4, 6])
y = tf.constant([5, 6, 6])
tf.math.less_equal(x, y) ==> [True, True, True]

 Args
  x   A Tensor. Must be one of the following types: float32, float64, int32, uint8, int16, int8, int64, bfloat16, uint16, half, uint32, uint64.
  y   A Tensor. Must have the same type as x.
  name   A name for the operation (optional).

 Returns   A Tensor of type bool.


tf.math.lgamma Computes the log of the absolute value of Gamma(x) element-wise.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.lgamma, tf.compat.v1.math.lgamma
tf.math.lgamma(
    x, name=None
)
 For positive numbers, this function computes log((input - 1)!) for every element in the tensor. lgamma(5) = log((5-1)!) = log(4!) = log(24) = 3.1780539 Example: x = tf.constant([0, 0.5, 1, 4.5, -4, -5.6])
tf.math.lgamma(x) ==> [inf, 0.5723649, 0., 2.4537368, inf, -4.6477685]

 Args
  x   A Tensor. Must be one of the following types: bfloat16, half, float32, float64.
  name   A name for the operation (optional).

 Returns   A Tensor. Has the same type as x.


tf.math.log   Computes natural logarithm of x element-wise.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.log, tf.compat.v1.math.log
tf.math.log(
    x, name=None
)
 I.e., \(y = \log_e x\). Example:  x = tf.constant([0, 0.5, 1, 5]) tf.math.log(x)   See: https://en.wikipedia.org/wiki/Logarithm

 Args
  x   A Tensor. Must be one of the following types: bfloat16, half, float32, float64, complex64, complex128.
  name   A name for the operation (optional).

 Returns   A Tensor. Has the same type as x.


tf.math.log1p   Computes natural logarithm of (1 + x) element-wise.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.log1p, tf.compat.v1.math.log1p
tf.math.log1p(
    x, name=None
)
 I.e., \(y = \log_e (1 + x)\). Example:
x = tf.constant([0, 0.5, 1, 5])
tf.math.log1p(x)
<tf.Tensor: shape=(4,), dtype=float32, numpy=array([0.       , 0.4054651, 0.6931472, 1.7917595], dtype=float32)>

 Args
  x   A Tensor. Must be one of the following types: bfloat16, half, float32, float64, complex64, complex128.
  name   A name for the operation (optional).

 Returns   A Tensor. Has the same type as x.


tf.math.logical_and     View source on GitHub    Logical AND function.  View aliases  Main aliases
tf.logical_and Compat aliases for migration See Migration guide for more details. tf.compat.v1.logical_and, tf.compat.v1.math.logical_and
tf.math.logical_and(
    x, y, name=None
)
 The operation works for the following input types:  Two single elements of type bool
 One tf.Tensor of type bool and one single bool, where the result will be calculated by applying logical AND with the single element to each element in the larger Tensor. Two tf.Tensor objects of type bool of the same shape. In this case, the result will be the element-wise logical AND of the two input tensors.  Usage:
a = tf.constant([True])
b = tf.constant([False])
tf.math.logical_and(a, b)
<tf.Tensor: shape=(1,), dtype=bool, numpy=array([False])>

c = tf.constant([True])
x = tf.constant([False, True, True, False])
tf.math.logical_and(c, x)
<tf.Tensor: shape=(4,), dtype=bool, numpy=array([False,  True,  True, False])>

y = tf.constant([False, False, True, True])
z = tf.constant([False, True, False, True])
tf.math.logical_and(y, z)
<tf.Tensor: shape=(4,), dtype=bool, numpy=array([False, False, False,  True])>

 Args
  x   A tf.Tensor type bool.
  y   A tf.Tensor of type bool.
  name   A name for the operation (optional).

 Returns   A tf.Tensor of type bool with the same size as that of x or y.


tf.math.logical_not Returns the truth value of NOT x element-wise.  View aliases  Main aliases
tf.logical_not Compat aliases for migration See Migration guide for more details. tf.compat.v1.logical_not, tf.compat.v1.math.logical_not
tf.math.logical_not(
    x, name=None
)
 Example:
tf.math.logical_not(tf.constant([True, False]))
<tf.Tensor: shape=(2,), dtype=bool, numpy=array([False,  True])>

 Args
  x   A Tensor of type bool. A Tensor of type bool.
  name   A name for the operation (optional).

 Returns   A Tensor of type bool.


tf.math.logical_or Returns the truth value of x OR y element-wise.  View aliases  Main aliases
tf.logical_or Compat aliases for migration See Migration guide for more details. tf.compat.v1.logical_or, tf.compat.v1.math.logical_or
tf.math.logical_or(
    x, y, name=None
)

Note: math.logical_or supports broadcasting. More about broadcasting here

 Args
  x   A Tensor of type bool.
  y   A Tensor of type bool.
  name   A name for the operation (optional).

 Returns   A Tensor of type bool.


tf.math.logical_xor     View source on GitHub    Logical XOR function.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.logical_xor, tf.compat.v1.math.logical_xor
tf.math.logical_xor(
    x, y, name='LogicalXor'
)
 x ^ y = (x | y) & ~(x & y) The operation works for the following input types:  Two single elements of type bool
 One tf.Tensor of type bool and one single bool, where the result will be calculated by applying logical XOR with the single element to each element in the larger Tensor. Two tf.Tensor objects of type bool of the same shape. In this case, the result will be the element-wise logical XOR of the two input tensors.  Usage:
a = tf.constant([True])
b = tf.constant([False])
tf.math.logical_xor(a, b)
<tf.Tensor: shape=(1,), dtype=bool, numpy=array([ True])>

c = tf.constant([True])
x = tf.constant([False, True, True, False])
tf.math.logical_xor(c, x)
<tf.Tensor: shape=(4,), dtype=bool, numpy=array([ True, False, False,  True])>

y = tf.constant([False, False, True, True])
z = tf.constant([False, True, False, True])
tf.math.logical_xor(y, z)
<tf.Tensor: shape=(4,), dtype=bool, numpy=array([False,  True,  True, False])>

 Args
  x   A tf.Tensor type bool.
  y   A tf.Tensor of type bool.
  name   A name for the operation (optional).

 Returns   A tf.Tensor of type bool with the same size as that of x or y.


tf.math.log_sigmoid     View source on GitHub    Computes log sigmoid of x element-wise.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.log_sigmoid, tf.compat.v1.math.log_sigmoid
tf.math.log_sigmoid(
    x, name=None
)
 Specifically, y = log(1 / (1 + exp(-x))). For numerical stability, we use y = -tf.nn.softplus(-x).

 Args
  x   A Tensor with type float32 or float64.
  name   A name for the operation (optional).

 Returns   A Tensor with the same type as x.
 Usage Example: If a positive number is large, then its log_sigmoid will approach to 0 since the formula will be y = log( <large_num> / (1 + <large_num>) ) which approximates to log (1) which is 0.
x = tf.constant([0.0, 1.0, 50.0, 100.0])
tf.math.log_sigmoid(x)
<tf.Tensor: shape=(4,), dtype=float32, numpy=
array([-6.9314718e-01, -3.1326169e-01, -1.9287499e-22, -0.0000000e+00],
      dtype=float32)>
 If a negative number is large, its log_sigmoid will approach to the number itself since the formula will be y = log( 1 / (1 + <large_num>) ) which is log (1) - log ( (1 + <large_num>) ) which approximates to - <large_num> that is the number itself.
x = tf.constant([-100.0, -50.0, -1.0, 0.0])
tf.math.log_sigmoid(x)
<tf.Tensor: shape=(4,), dtype=float32, numpy=
array([-100.       ,  -50.       ,   -1.3132616,   -0.6931472],
      dtype=float32)>


tf.math.maximum Returns the max of x and y (i.e. x > y ? x : y) element-wise.  View aliases  Main aliases
tf.maximum Compat aliases for migration See Migration guide for more details. tf.compat.v1.math.maximum, tf.compat.v1.maximum
tf.math.maximum(
    x, y, name=None
)
 Example:
x = tf.constant([0., 0., 0., 0.])
y = tf.constant([-2., 0., 2., 5.])
tf.math.maximum(x, y)
<tf.Tensor: shape=(4,), dtype=float32, numpy=array([0., 0., 2., 5.], dtype=float32)>

 Args
  x   A Tensor. Must be one of the following types: bfloat16, half, float32, float64, uint8, int16, int32, int64.
  y   A Tensor. Must have the same type as x.
  name   A name for the operation (optional).

 Returns   A Tensor. Has the same type as x.


tf.math.minimum Returns the min of x and y (i.e. x < y ? x : y) element-wise.  View aliases  Main aliases
tf.minimum Compat aliases for migration See Migration guide for more details. tf.compat.v1.math.minimum, tf.compat.v1.minimum
tf.math.minimum(
    x, y, name=None
)
 Both inputs are number-type tensors (except complex). minimum expects that both tensors have the same dtype. Examples:
x = tf.constant([0., 0., 0., 0.])
y = tf.constant([-5., -2., 0., 3.])
tf.math.minimum(x, y)
<tf.Tensor: shape=(4,), dtype=float32, numpy=array([-5., -2., 0., 0.], dtype=float32)>
 Note that minimum supports broadcast semantics.
x = tf.constant([-5., 0., 0., 0.])
y = tf.constant([-3.])
tf.math.minimum(x, y)
<tf.Tensor: shape=(4,), dtype=float32, numpy=array([-5., -3., -3., -3.], dtype=float32)>
 If inputs are not tensors, they will be converted to tensors. See tf.convert_to_tensor.
x = tf.constant([-3.], dtype=tf.float32)
tf.math.minimum([-5], x)
<tf.Tensor: shape=(1,), dtype=float32, numpy=array([-5.], dtype=float32)>

 Args
  x   A Tensor. Must be one of the following types: bfloat16, half, float32, float64, uint8, int16, int32, int64.
  y   A Tensor. Must have the same type as x.
  name   A name for the operation (optional).

 Returns   A Tensor. Has the same type as x.


tf.math.multiply     View source on GitHub    Returns an element-wise x * y.  View aliases  Main aliases
tf.multiply Compat aliases for migration See Migration guide for more details. tf.compat.v1.math.multiply, tf.compat.v1.multiply
tf.math.multiply(
    x, y, name=None
)
 For example:
x = tf.constant(([1, 2, 3, 4]))
tf.math.multiply(x, x)
<tf.Tensor: shape=(4,), dtype=..., numpy=array([ 1,  4,  9, 16], dtype=int32)>
 Since tf.math.multiply will convert its arguments to Tensors, you can also pass in non-Tensor arguments:
tf.math.multiply(7,6)
<tf.Tensor: shape=(), dtype=int32, numpy=42>
 If x.shape is not thes same as y.shape, they will be broadcast to a compatible shape. (More about broadcasting here.) For example:
x = tf.ones([1, 2]);
y = tf.ones([2, 1]);
x * y  # Taking advantage of operator overriding
<tf.Tensor: shape=(2, 2), dtype=float32, numpy=
array([[1., 1.],
     [1., 1.]], dtype=float32)>

 Args
  x   A Tensor. Must be one of the following types: bfloat16, half, float32, float64, uint8, int8, uint16, int16, int32, int64, complex64, complex128.
  y   A Tensor. Must have the same type as x.
  name   A name for the operation (optional).

 Returns
 A Tensor. Has the same type as x.

 Raises    InvalidArgumentError: When x and y have incomptatible shapes or types.


tf.math.multiply_no_nan     View source on GitHub    Computes the product of x and y and returns 0 if the y is zero, even if x is NaN or infinite.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.math.multiply_no_nan
tf.math.multiply_no_nan(
    x, y, name=None
)

 Args
  x   A Tensor. Must be one of the following types: float32, float64.
  y   A Tensor whose dtype is compatible with x.
  name   A name for the operation (optional).

 Returns   The element-wise value of the x times y.


tf.math.ndtri Compute quantile of Standard Normal.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.math.ndtri
tf.math.ndtri(
    x, name=None
)

 Args
  x   Tensor with type float or double.
  name   A name for the operation (optional).

 Returns   Inverse error function of x.


tf.math.negative   Computes numerical negative value element-wise.  View aliases  Main aliases
tf.negative Compat aliases for migration See Migration guide for more details. tf.compat.v1.math.negative, tf.compat.v1.negative
tf.math.negative(
    x, name=None
)
 I.e., \(y = -x\).

 Args
  x   A Tensor. Must be one of the following types: bfloat16, half, float32, float64, int8, int16, int32, int64, complex64, complex128.
  name   A name for the operation (optional).

 Returns   A Tensor. Has the same type as x. If x is a SparseTensor, returns SparseTensor(x.indices, tf.math.negative(x.values, ...), x.dense_shape)


tf.math.nextafter Returns the next representable value of x1 in the direction of x2, element-wise.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.math.nextafter
tf.math.nextafter(
    x1, x2, name=None
)
 This operation returns the same result as the C++ std::nextafter function. It can also return a subnormal number.

 Args
  x1   A Tensor. Must be one of the following types: float64, float32.
  x2   A Tensor. Must have the same type as x1.
  name   A name for the operation (optional).

 Returns   A Tensor. Has the same type as x1.
 Cpp Compatibility Equivalent to C++ std::nextafter function.


tf.math.not_equal     View source on GitHub    Returns the truth value of (x != y) element-wise.  View aliases  Main aliases
tf.not_equal Compat aliases for migration See Migration guide for more details. tf.compat.v1.math.not_equal, tf.compat.v1.not_equal
tf.math.not_equal(
    x, y, name=None
)
 Performs a broadcast with the arguments and then an element-wise inequality comparison, returning a Tensor of boolean values. For example:
x = tf.constant([2, 4])
y = tf.constant(2)
tf.math.not_equal(x, y)
<tf.Tensor: shape=(2,), dtype=bool, numpy=array([False,  True])>

x = tf.constant([2, 4])
y = tf.constant([2, 4])
tf.math.not_equal(x, y)
<tf.Tensor: shape=(2,), dtype=bool, numpy=array([False,  False])>

 Args
  x   A tf.Tensor or tf.sparse.SparseTensor or tf.IndexedSlices.
  y   A tf.Tensor or tf.sparse.SparseTensor or tf.IndexedSlices.
  name   A name for the operation (optional).

 Returns   A tf.Tensor of type bool with the same size as that of x or y.

 Raises   tf.errors.InvalidArgumentError: If shapes of arguments are incompatible


tf.math.polygamma   Compute the polygamma function \(\psi^{(n)}(x)\).  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.math.polygamma, tf.compat.v1.polygamma
tf.math.polygamma(
    a, x, name=None
)
 The polygamma function is defined as: \(\psi^{(a)}(x) = \frac{d^a}{dx^a} \psi(x)\) where \(\psi(x)\) is the digamma function. The polygamma function is defined only for non-negative integer orders \a\.

 Args
  a   A Tensor. Must be one of the following types: float32, float64.
  x   A Tensor. Must have the same type as a.
  name   A name for the operation (optional).

 Returns   A Tensor. Has the same type as a.