neulab/docprompting-conala huggingface dataset:
tf.math.polyval     View source on GitHub    Computes the elementwise value of a polynomial.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.math.polyval  
tf.math.polyval(
    coeffs, x, name=None
)
 If x is a tensor and coeffs is a list n + 1 tensors, this function returns the value of the n-th order polynomial p(x) = coeffs[n-1] + coeffs[n-2] * x + ... + coeffs[0] * x**(n-1) evaluated using Horner's method, i.e. `p(x) = coeffs[n-1] + x * (coeffs[n-2] + ... + x * (coeffs[1] + x * coeffs[0]))`
 Usage Example: 
coefficients = [1.0, 2.5, -4.2]
x = 5.0
y = tf.math.polyval(coefficients, x)
y
<tf.Tensor: shape=(), dtype=float32, numpy=33.3>
 Usage Example: 
tf.math.polyval([2, 1, 0], 3) # evaluates 2 * (3**2) + 1 * (3**1) + 0 * (3**0)
<tf.Tensor: shape=(), dtype=int32, numpy=21>
 tf.math.polyval can also be used in polynomial regression. Taking advantage of this function can facilitate writing a polynomial equation as compared to explicitly writing it out, especially for higher degree polynomials. 
x = tf.constant(3)
theta1 = tf.Variable(2)
theta2 = tf.Variable(1)
theta3 = tf.Variable(0)
tf.math.polyval([theta1, theta2, theta3], x)
<tf.Tensor: shape=(), dtype=int32, numpy=21>

 


 Args
  coeffs   A list of Tensor representing the coefficients of the polynomial.  
  x   A Tensor representing the variable of the polynomial.  
  name   A name for the operation (optional).   
 


 Returns   A tensor of the shape as the expression p(x) with usual broadcasting rules for element-wise addition and multiplication applied.  
 Numpy Compatibility Equivalent to numpy.polyval.
tf.math.pow       View source on GitHub    Computes the power of one value to another.  View aliases  Main aliases 
tf.pow Compat aliases for migration See Migration guide for more details. tf.compat.v1.math.pow, tf.compat.v1.pow  
tf.math.pow(
    x, y, name=None
)
 Given a tensor x and a tensor y, this operation computes \(x^y\) for corresponding elements in x and y. For example: x = tf.constant([[2, 2], [3, 3]])
y = tf.constant([[8, 16], [2, 3]])
tf.pow(x, y)  # [[256, 65536], [9, 27]]

 


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


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


 Args
  input   A Tensor. Must have numeric type.  
  name   A name for the operation (optional).   
 


 Returns   A Tensor of type float32 or float64.
tf.math.reciprocal   Computes the reciprocal of x element-wise.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.math.reciprocal, tf.compat.v1.reciprocal  
tf.math.reciprocal(
    x, name=None
)
 I.e., \(y = 1 / 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.reciprocal_no_nan     View source on GitHub    Performs a safe reciprocal operation, element wise.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.math.reciprocal_no_nan  
tf.math.reciprocal_no_nan(
    x, name=None
)
 If a particular element is zero, the reciprocal for that element is also set to zero. For example: x = tf.constant([2.0, 0.5, 0, 1], dtype=tf.float32)
tf.math.reciprocal_no_nan(x)  # [ 0.5, 2, 0.0, 1.0 ]

 


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


 Returns   A Tensor of same shape and type as x.  

 


 Raises
  TypeError   x must be of a valid dtype.
tf.math.reduce_all     View source on GitHub    Computes the "logical and" of elements across dimensions of a tensor.  View aliases  Main aliases 
tf.reduce_all  
tf.math.reduce_all(
    input_tensor, axis=None, keepdims=False, name=None
)
 Reduces input_tensor along the dimensions given in axis. Unless keepdims is true, the rank of the tensor is reduced by 1 for each of the entries in axis, which must be unique. If keepdims is true, the reduced dimensions are retained with length 1. If axis is None, all dimensions are reduced, and a tensor with a single element is returned. For example: x = tf.constant([[True,  True], [False, False]])
tf.reduce_all(x)  # False
tf.reduce_all(x, 0)  # [False, False]
tf.reduce_all(x, 1)  # [True, False]

 


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


 Returns   The reduced tensor.  
 Numpy Compatibility Equivalent to np.all
tf.math.reduce_any     View source on GitHub    Computes the "logical or" of elements across dimensions of a tensor.  View aliases  Main aliases 
tf.reduce_any  
tf.math.reduce_any(
    input_tensor, axis=None, keepdims=False, name=None
)
 Reduces input_tensor along the dimensions given in axis. Unless keepdims is true, the rank of the tensor is reduced by 1 for each of the entries in axis, which must be unique. If keepdims is true, the reduced dimensions are retained with length 1. If axis is None, all dimensions are reduced, and a tensor with a single element is returned. For example: x = tf.constant([[True,  True], [False, False]])
tf.reduce_any(x)  # True
tf.reduce_any(x, 0)  # [True, True]
tf.reduce_any(x, 1)  # [True, False]

 


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


 Returns   The reduced tensor.  
 Numpy Compatibility Equivalent to np.any
tf.math.reduce_euclidean_norm     View source on GitHub    Computes the Euclidean norm of elements across dimensions of a tensor.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.math.reduce_euclidean_norm  
tf.math.reduce_euclidean_norm(
    input_tensor, axis=None, keepdims=False, name=None
)
 Reduces input_tensor along the dimensions given in axis. Unless keepdims is true, the rank of the tensor is reduced by 1 for each of the entries in axis, which must be unique. If keepdims is true, the reduced dimensions are retained with length 1. If axis is None, all dimensions are reduced, and a tensor with a single element is returned. For example: x = tf.constant([[1, 2, 3], [1, 1, 1]]) # x.dtype is tf.int32
tf.math.reduce_euclidean_norm(x)  # returns 4 as dtype is tf.int32
y = tf.constant([[1, 2, 3], [1, 1, 1]], dtype = tf.float32)
tf.math.reduce_euclidean_norm(y)  # returns 4.1231055 which is sqrt(17)
tf.math.reduce_euclidean_norm(y, 0)  # [sqrt(2), sqrt(5), sqrt(10)]
tf.math.reduce_euclidean_norm(y, 1)  # [sqrt(14), sqrt(3)]
tf.math.reduce_euclidean_norm(y, 1, keepdims=True)  # [[sqrt(14)], [sqrt(3)]]
tf.math.reduce_euclidean_norm(y, [0, 1])  # sqrt(17)

 


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


 Returns   The reduced tensor, of the same dtype as the input_tensor.
tf.math.reduce_logsumexp     View source on GitHub    Computes log(sum(exp(elements across dimensions of a tensor))).  View aliases  Main aliases 
tf.reduce_logsumexp  
tf.math.reduce_logsumexp(
    input_tensor, axis=None, keepdims=False, name=None
)
 Reduces input_tensor along the dimensions given in axis. Unless keepdims is true, the rank of the tensor is reduced by 1 for each of the entries in axis, which must be unique. If keepdims is true, the reduced dimensions are retained with length 1. If axis has no entries, all dimensions are reduced, and a tensor with a single element is returned. This function is more numerically stable than log(sum(exp(input))). It avoids overflows caused by taking the exp of large inputs and underflows caused by taking the log of small inputs. For example: x = tf.constant([[0., 0., 0.], [0., 0., 0.]])
tf.reduce_logsumexp(x)  # log(6)
tf.reduce_logsumexp(x, 0)  # [log(2), log(2), log(2)]
tf.reduce_logsumexp(x, 1)  # [log(3), log(3)]
tf.reduce_logsumexp(x, 1, keepdims=True)  # [[log(3)], [log(3)]]
tf.reduce_logsumexp(x, [0, 1])  # log(6)

 


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


 Returns   The reduced tensor.
tf.math.reduce_max     View source on GitHub    Computes the maximum of elements across dimensions of a tensor.  View aliases  Main aliases 
tf.reduce_max  
tf.math.reduce_max(
    input_tensor, axis=None, keepdims=False, name=None
)
 Reduces input_tensor along the dimensions given in axis. Unless keepdims is true, the rank of the tensor is reduced by 1 for each of the entries in axis, which must be unique. If keepdims is true, the reduced dimensions are retained with length 1. If axis is None, all dimensions are reduced, and a tensor with a single element is returned. Usage example: 
x = tf.constant([5, 1, 2, 4])
print(tf.reduce_max(x))
tf.Tensor(5, shape=(), dtype=int32)
x = tf.constant([-5, -1, -2, -4])
print(tf.reduce_max(x))
tf.Tensor(-1, shape=(), dtype=int32)
x = tf.constant([4, float('nan')])
print(tf.reduce_max(x))
tf.Tensor(nan, shape=(), dtype=float32)
x = tf.constant([float('nan'), float('nan')])
print(tf.reduce_max(x))
tf.Tensor(nan, shape=(), dtype=float32)
x = tf.constant([float('-inf'), float('inf')])
print(tf.reduce_max(x))
tf.Tensor(inf, shape=(), dtype=float32)
 See the numpy docs for np.amax and np.nanmax behavior.
 


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


 Returns   The reduced tensor.
tf.math.reduce_mean     View source on GitHub    Computes the mean of elements across dimensions of a tensor.  View aliases  Main aliases 
tf.reduce_mean  
tf.math.reduce_mean(
    input_tensor, axis=None, keepdims=False, name=None
)
 Reduces input_tensor along the dimensions given in axis by computing the mean of elements across the dimensions in axis. Unless keepdims is true, the rank of the tensor is reduced by 1 for each of the entries in axis, which must be unique. If keepdims is true, the reduced dimensions are retained with length 1. If axis is None, all dimensions are reduced, and a tensor with a single element is returned. For example: 
x = tf.constant([[1., 1.], [2., 2.]])
tf.reduce_mean(x)
<tf.Tensor: shape=(), dtype=float32, numpy=1.5>
tf.reduce_mean(x, 0)
<tf.Tensor: shape=(2,), dtype=float32, numpy=array([1.5, 1.5], dtype=float32)>
tf.reduce_mean(x, 1)
<tf.Tensor: shape=(2,), dtype=float32, numpy=array([1., 2.], dtype=float32)>

 


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


 Returns   The reduced tensor.  
 Numpy Compatibility Equivalent to np.mean Please note that np.mean has a dtype parameter that could be used to specify the output type. By default this is dtype=float64. On the other hand, tf.reduce_mean has an aggressive type inference from input_tensor, for example: 
x = tf.constant([1, 0, 1, 0])
tf.reduce_mean(x)
<tf.Tensor: shape=(), dtype=int32, numpy=0>
y = tf.constant([1., 0., 1., 0.])
tf.reduce_mean(y)
<tf.Tensor: shape=(), dtype=float32, numpy=0.5>
tf.math.reduce_min     View source on GitHub    Computes the minimum of elements across dimensions of a tensor.  View aliases  Main aliases 
tf.reduce_min  
tf.math.reduce_min(
    input_tensor, axis=None, keepdims=False, name=None
)
 Reduces input_tensor along the dimensions given in axis. Unless keepdims is true, the rank of the tensor is reduced by 1 for each of the entries in axis, which must be unique. If keepdims is true, the reduced dimensions are retained with length 1. If axis is None, all dimensions are reduced, and a tensor with a single element is returned.
 


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


 Returns   The reduced tensor.  
 For example: 
a = tf.constant([[1, 2], [3, 4]])
tf.reduce_min(a)
<tf.Tensor: shape=(), dtype=int32, numpy=1>
 Numpy Compatibility Equivalent to np.min
tf.math.reduce_prod     View source on GitHub    Computes the product of elements across dimensions of a tensor.  View aliases  Main aliases 
tf.reduce_prod  
tf.math.reduce_prod(
    input_tensor, axis=None, keepdims=False, name=None
)
 Reduces input_tensor 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 is None, all dimensions are reduced, and a tensor with a single element is returned.
 


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


 Returns   The reduced tensor.  
 Numpy Compatibility Equivalent to np.prod
tf.math.reduce_std     View source on GitHub    Computes the standard deviation of elements across dimensions of a tensor.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.math.reduce_std  
tf.math.reduce_std(
    input_tensor, axis=None, keepdims=False, name=None
)
 Reduces input_tensor along the dimensions given in axis. Unless keepdims is true, the rank of the tensor is reduced by 1 for each of the entries in axis, which must be unique. If keepdims is true, the reduced dimensions are retained with length 1. If axis is None, all dimensions are reduced, and a tensor with a single element is returned. For example: 
x = tf.constant([[1., 2.], [3., 4.]])
tf.math.reduce_std(x)
<tf.Tensor: shape=(), dtype=float32, numpy=1.118034>
tf.math.reduce_std(x, 0)
<tf.Tensor: shape=(2,), dtype=float32, numpy=array([1., 1.], dtype=float32)>
tf.math.reduce_std(x, 1)
<tf.Tensor: shape=(2,), dtype=float32, numpy=array([0.5, 0.5], dtype=float32)>

 


 Args
  input_tensor   The tensor to reduce. Should have real or complex type.  
  axis   The dimensions to reduce. If None (the default), reduces all dimensions. Must be in the range [-rank(input_tensor), rank(input_tensor)).  
  keepdims   If true, retains reduced dimensions with length 1.  
  name   A name scope for the associated operations (optional).   
 


 Returns   The reduced tensor, of the same dtype as the input_tensor. Note, for complex64 or complex128 input, the returned Tensor will be of type float32 or float64, respectively.  
 Numpy Compatibility Equivalent to np.std Please note np.std has a dtype parameter that could be used to specify the output type. By default this is dtype=float64. On the other hand, tf.math.reduce_std has aggressive type inference from input_tensor.
tf.math.reduce_sum     View source on GitHub    Computes the sum of elements across dimensions of a tensor.  View aliases  Main aliases 
tf.reduce_sum  
tf.math.reduce_sum(
    input_tensor, axis=None, keepdims=False, name=None
)
 Reduces input_tensor along the dimensions given in axis. Unless keepdims is true, the rank of the tensor is reduced by 1 for each of the entries in axis, which must be unique. If keepdims is true, the reduced dimensions are retained with length 1. If axis is None, all dimensions are reduced, and a tensor with a single element is returned. For example: 
# x has a shape of (2, 3) (two rows and three columns):
x = tf.constant([[1, 1, 1], [1, 1, 1]])
x.numpy()
array([[1, 1, 1],
       [1, 1, 1]], dtype=int32)
# sum all the elements
# 1 + 1 + 1 + 1 + 1+ 1 = 6
tf.reduce_sum(x).numpy()
6
# reduce along the first dimension
# the result is [1, 1, 1] + [1, 1, 1] = [2, 2, 2]
tf.reduce_sum(x, 0).numpy()
array([2, 2, 2], dtype=int32)
# reduce along the second dimension
# the result is [1, 1] + [1, 1] + [1, 1] = [3, 3]
tf.reduce_sum(x, 1).numpy()
array([3, 3], dtype=int32)
# keep the original dimensions
tf.reduce_sum(x, 1, keepdims=True).numpy()
array([[3],
       [3]], dtype=int32)
# reduce along both dimensions
# the result is 1 + 1 + 1 + 1 + 1 + 1 = 6
# or, equivalently, reduce along rows, then reduce the resultant array
# [1, 1, 1] + [1, 1, 1] = [2, 2, 2]
# 2 + 2 + 2 = 6
tf.reduce_sum(x, [0, 1]).numpy()
6

 


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


 Returns   The reduced tensor, of the same dtype as the input_tensor.  
 Numpy Compatibility Equivalent to np.sum apart the fact that numpy upcast uint8 and int32 to int64 while tensorflow returns the same dtype as the input.
tf.math.reduce_variance     View source on GitHub    Computes the variance of elements across dimensions of a tensor.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.math.reduce_variance  
tf.math.reduce_variance(
    input_tensor, axis=None, keepdims=False, name=None
)
 Reduces input_tensor along the dimensions given in axis. Unless keepdims is true, the rank of the tensor is reduced by 1 for each of the entries in axis, which must be unique. If keepdims is true, the reduced dimensions are retained with length 1. If axis is None, all dimensions are reduced, and a tensor with a single element is returned. For example: 
x = tf.constant([[1., 2.], [3., 4.]])
tf.math.reduce_variance(x)
<tf.Tensor: shape=(), dtype=float32, numpy=1.25>
tf.math.reduce_variance(x, 0)
<tf.Tensor: shape=(2,), dtype=float32, numpy=array([1., 1.], ...)>
tf.math.reduce_variance(x, 1)
<tf.Tensor: shape=(2,), dtype=float32, numpy=array([0.25, 0.25], ...)>

 


 Args
  input_tensor   The tensor to reduce. Should have real or complex type.  
  axis   The dimensions to reduce. If None (the default), reduces all dimensions. Must be in the range [-rank(input_tensor), rank(input_tensor)).  
  keepdims   If true, retains reduced dimensions with length 1.  
  name   A name scope for the associated operations (optional).   
 


 Returns   The reduced tensor, of the same dtype as the input_tensor. Note, for complex64 or complex128 input, the returned Tensor will be of type float32 or float64, respectively.  
 Numpy Compatibility Equivalent to np.var Please note np.var has a dtype parameter that could be used to specify the output type. By default this is dtype=float64. On the other hand, tf.math.reduce_variance has aggressive type inference from input_tensor.
tf.math.rint Returns element-wise integer closest to x.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.math.rint, tf.compat.v1.rint  
tf.math.rint(
    x, name=None
)
 If the result is midway between two representable values, the even representable is chosen. For example: rint(-1.5) ==> -2.0
rint(0.5000001) ==> 1.0
rint([-1.7, -1.5, -0.2, 0.2, 1.5, 1.7, 2.0]) ==> [-2., -2., -0., 0., 2., 2., 2.]

 


 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.round     View source on GitHub    Rounds the values of a tensor to the nearest integer, element-wise.  View aliases  Main aliases 
tf.round Compat aliases for migration See Migration guide for more details. tf.compat.v1.math.round, tf.compat.v1.round  
tf.math.round(
    x, name=None
)
 Rounds half to even. Also known as bankers rounding. If you want to round according to the current system rounding mode use tf::cint. For example: x = tf.constant([0.9, 2.5, 2.3, 1.5, -4.5])
tf.round(x)  # [ 1.0, 2.0, 2.0, 2.0, -4.0 ]

 


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


 Returns   A Tensor of same shape and type as x.
tf.math.rsqrt     View source on GitHub    Computes reciprocal of square root of x element-wise.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.math.rsqrt, tf.compat.v1.rsqrt  
tf.math.rsqrt(
    x, name=None
)
 For example: 
x = tf.constant([2., 0., -2.])
tf.math.rsqrt(x)
<tf.Tensor: shape=(3,), dtype=float32,
numpy=array([0.707, inf, nan], dtype=float32)>

 


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


 Returns   A tf.Tensor. Has the same type as x.
tf.math.scalar_mul     View source on GitHub    Multiplies a scalar times a Tensor or IndexedSlices object.  View aliases  Main aliases 
tf.scalar_mul  
tf.math.scalar_mul(
    scalar, x, name=None
)
 Intended for use in gradient code which might deal with IndexedSlices objects, which are easy to multiply by a scalar but more expensive to multiply with arbitrary tensors.
 


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


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

 


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