neulab/docprompting-conala huggingface dataset:
tf.linalg.trace     View source on GitHub    Compute the trace of a tensor x.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.linalg.trace, tf.compat.v1.trace  
tf.linalg.trace(
    x, name=None
)
 trace(x) returns the sum along the main diagonal of each inner-most matrix in x. If x is of rank k with shape [I, J, K, ..., L, M, N], then output is a tensor of rank k-2 with dimensions [I, J, K, ..., L] where output[i, j, k, ..., l] = trace(x[i, j, k, ..., l, :, :]) For example: x = tf.constant([[1, 2], [3, 4]])
tf.linalg.trace(x)  # 5

x = tf.constant([[1, 2, 3],
                 [4, 5, 6],
                 [7, 8, 9]])
tf.linalg.trace(x)  # 15

x = tf.constant([[[1, 2, 3],
                  [4, 5, 6],
                  [7, 8, 9]],
                 [[-1, -2, -3],
                  [-4, -5, -6],
                  [-7, -8, -9]]])
tf.linalg.trace(x)  # [15, -15]

 


 Args
  x   tensor.  
  name   A name for the operation (optional).   
 


 Returns   The trace of input tensor.
tf.linalg.triangular_solve     View source on GitHub    Solve systems of linear equations with upper or lower triangular matrices.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.linalg.triangular_solve, tf.compat.v1.matrix_triangular_solve  
tf.linalg.triangular_solve(
    matrix, rhs, lower=True, adjoint=False, name=None
)
 matrix is a tensor of shape [..., M, M] whose inner-most 2 dimensions form square matrices. If lower is True then the strictly upper triangular part of each inner-most matrix is assumed to be zero and not accessed. If lower is False then the strictly lower triangular part of each inner-most matrix is assumed to be zero and not accessed. rhs is a tensor of shape [..., M, N]. The output is a tensor of shape [..., M, N]. If adjoint is True then the innermost matrices in output satisfy matrix equations sum_k matrix[..., i, k] * output[..., k, j] = rhs[..., i, j]. If adjoint is False then the innermost matrices in output satisfy matrix equations sum_k adjoint(matrix[..., i, k]) * output[..., k, j] = rhs[..., i, j]. Example: 
a = tf.constant([[3,  0,  0,  0],
  [2,  1,  0,  0],
  [1,  0,  1,  0],
  [1,  1,  1,  1]], dtype=tf.float32)
 
b = tf.constant([[4], [2], [4], [2]], dtype=tf.float32)
x = tf.linalg.triangular_solve(a, b, lower=True)
x
<tf.Tensor: shape=(4, 1), dtype=float32, numpy=
array([[ 1.3333334 ],
       [-0.66666675],
       [ 2.6666665 ],
       [-1.3333331 ]], dtype=float32)>
tf.matmul(a, x)
<tf.Tensor: shape=(4, 1), dtype=float32, numpy=
array([[4.],
       [2.],
       [4.],
       [2.]], dtype=float32)>

 


 Args
  matrix   A Tensor. Must be one of the following types: float64, float32, half, complex64, complex128. Shape is [..., M, M].  
  rhs   A Tensor. Must have the same type as matrix. Shape is [..., M, N].  
  lower   An optional bool. Defaults to True. Boolean indicating whether the innermost matrices in matrix are lower or upper triangular.  
  adjoint   An optional bool. Defaults to False. Boolean indicating whether to solve with matrix or its (block-wise) adjoint.  
  name   A name for the operation (optional).   
 


 Returns   A Tensor. Has the same type as matrix, and shape is [..., M, N].
tf.linalg.tridiagonal_matmul     View source on GitHub    Multiplies tridiagonal matrix by matrix.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.linalg.tridiagonal_matmul  
tf.linalg.tridiagonal_matmul(
    diagonals, rhs, diagonals_format='compact', name=None
)
 diagonals is representation of 3-diagonal NxN matrix, which depends on diagonals_format. In matrix format, diagonals must be a tensor of shape [..., M, M], with two inner-most dimensions representing the square tridiagonal matrices. Elements outside of the three diagonals will be ignored. If sequence format, diagonals is list or tuple of three tensors: [superdiag, maindiag, subdiag], each having shape [..., M]. Last element of superdiag first element of subdiag are ignored. In compact format the three diagonals are brought together into one tensor of shape [..., 3, M], with last two dimensions containing superdiagonals, diagonals, and subdiagonals, in order. Similarly to sequence format, elements diagonals[..., 0, M-1] and diagonals[..., 2, 0] are ignored. The sequence format is recommended as the one with the best performance. rhs is matrix to the right of multiplication. It has shape [..., M, N]. Example: superdiag = tf.constant([-1, -1, 0], dtype=tf.float64)
maindiag = tf.constant([2, 2, 2], dtype=tf.float64)
subdiag = tf.constant([0, -1, -1], dtype=tf.float64)
diagonals = [superdiag, maindiag, subdiag]
rhs = tf.constant([[1, 1], [1, 1], [1, 1]], dtype=tf.float64)
x = tf.linalg.tridiagonal_matmul(diagonals, rhs, diagonals_format='sequence')

 


 Args
  diagonals   A Tensor or tuple of Tensors describing left-hand sides. The shape depends of diagonals_format, see description above. Must be float32, float64, complex64, or complex128.  
  rhs   A Tensor of shape [..., M, N] and with the same dtype as diagonals.  
  diagonals_format   one of sequence, or compact. Default is compact.  
  name   A name to give this Op (optional).   
 


 Returns   A Tensor of shape [..., M, N] containing the result of multiplication.  

 


 Raises
  ValueError   An unsupported type is provided as input, or when the input tensors have incorrect shapes.
tf.linspace     View source on GitHub    Generates evenly-spaced values in an interval along a given axis.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.lin_space, tf.compat.v1.linspace  
tf.linspace(
    start, stop, num, name=None, axis=0
)
 A sequence of num evenly-spaced values are generated beginning at start along a given axis. If num > 1, the values in the sequence increase by stop - start / num - 1, so that the last one is exactly stop. If num <= 0, ValueError is raised. Matches np.linspace's behaviour except when num == 0. For example: tf.linspace(10.0, 12.0, 3, name="linspace") => [ 10.0  11.0  12.0]
 Start and stop can be tensors of arbitrary size: 
tf.linspace([0., 5.], [10., 40.], 5, axis=0)
<tf.Tensor: shape=(5, 2), dtype=float32, numpy=
array([[ 0.  ,  5.  ],
       [ 2.5 , 13.75],
       [ 5.  , 22.5 ],
       [ 7.5 , 31.25],
       [10.  , 40.  ]], dtype=float32)>
 Axis is where the values will be generated (the dimension in the returned tensor which corresponds to the axis will be equal to num) 
tf.linspace([0., 5.], [10., 40.], 5, axis=-1)
<tf.Tensor: shape=(2, 5), dtype=float32, numpy=
array([[ 0.  ,  2.5 ,  5.  ,  7.5 , 10.  ],
       [ 5.  , 13.75, 22.5 , 31.25, 40.  ]], dtype=float32)>

 


 Args
  start   A Tensor. Must be one of the following types: bfloat16, float32, float64. N-D tensor. First entry in the range.  
  stop   A Tensor. Must have the same type and shape as start. N-D tensor. Last entry in the range.  
  num   A Tensor. Must be one of the following types: int32, int64. 0-D tensor. Number of values to generate.  
  name   A name for the operation (optional).  
  axis   Axis along which the operation is performed (used only when N-D tensors are provided).   
 


 Returns   A Tensor. Has the same type as start.
Module: tf.lite Public API for tf.lite namespace. Modules experimental module: Public API for tf.lite.experimental namespace. Classes class Interpreter: Interpreter interface for TensorFlow Lite Models. class OpsSet: Enum class defining the sets of ops available to generate TFLite models. class Optimize: Enum defining the optimizations to apply when generating tflite graphs. class RepresentativeDataset: Representative dataset to evaluate optimizations. class TFLiteConverter: Converts a TensorFlow model into TensorFlow Lite model. class TargetSpec: Specification of target device.
Module: tf.lite.experimental Public API for tf.lite.experimental namespace. Functions load_delegate(...): Returns loaded Delegate object.
tf.lite.experimental.load_delegate     View source on GitHub    Returns loaded Delegate object.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.lite.experimental.load_delegate  
tf.lite.experimental.load_delegate(
    library, options=None
)

 


 Args
  library   Name of shared library containing the TfLiteDelegate.  
  options   Dictionary of options that are required to load the delegate. All keys and values in the dictionary should be convertible to str. Consult the documentation of the specific delegate for required and legal options. (default None)   
 


 Returns   Delegate object.  

 


 Raises
  ValueError   Delegate failed to load.  
  RuntimeError   If delegate loading is used on unsupported platform.
tf.lite.OpsSet     View source on GitHub    Enum class defining the sets of ops available to generate TFLite models.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.lite.OpsSet  Warning: Experimental interface, subject to change.
 


 Class Variables
  EXPERIMENTAL_TFLITE_BUILTINS_ACTIVATIONS_INT16_WEIGHTS_INT8   tf.lite.OpsSet  
  SELECT_TF_OPS   tf.lite.OpsSet  
  TFLITE_BUILTINS   tf.lite.OpsSet  
  TFLITE_BUILTINS_INT8   tf.lite.OpsSet
tf.lite.Optimize     View source on GitHub    Enum defining the optimizations to apply when generating tflite graphs.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.lite.Optimize  Some optimizations may come at the cost of accuracy. DEFAULT Default optimization strategy. Converter will do its best to improve size and latency based on the
information provided.
Enhanced optimizations are gained by providing a representative_dataset.
This is recommended, and is currently equivalent to the modes below.
Currently, weights will be quantized and if representative_dataset is
provided, activations for quantizable operations will also be quantized.
 OPTIMIZE_FOR_SIZE Deprecated. Does the same as DEFAULT. OPTIMIZE_FOR_LATENCY Deprecated. Does the same as DEFAULT.
 


 Class Variables
  DEFAULT   tf.lite.Optimize  
  OPTIMIZE_FOR_LATENCY   tf.lite.Optimize  
  OPTIMIZE_FOR_SIZE   tf.lite.Optimize
tf.lite.RepresentativeDataset     View source on GitHub    Representative dataset to evaluate optimizations.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.lite.RepresentativeDataset  
tf.lite.RepresentativeDataset(
    input_gen
)
 A representative dataset that can be used to evaluate optimizations by the converter. E.g. converter can use these examples to estimate (min, max) ranges by calibrating the model on inputs. This can allow converter to quantize a converted floating point model.
 


 Args
  input_gen   an input generator that can be used to generate input samples for the model. This must be a callable object that returns an object that supports the iter() protocol (e.g. a generator function). The elements generated must have same type and shape as inputs to the model.
tf.lite.TargetSpec     View source on GitHub    Specification of target device.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.lite.TargetSpec  
tf.lite.TargetSpec(
    supported_ops=None, supported_types=None
)
 Details about target device. Converter optimizes the generated model for specific device.
 


 Attributes
  supported_ops   Experimental flag, subject to change. Set of OpsSet options supported by the device. (default set([OpsSet.TFLITE_BUILTINS]))  
  supported_types   List of types for constant values on the target device. Frequently, an optimization choice is driven by the most compact (i.e. smallest) type in this list (default [tf.float32])
tf.load_library     View source on GitHub    Loads a TensorFlow plugin.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.load_library  
tf.load_library(
    library_location
)
 "library_location" can be a path to a specific shared object, or a folder. If it is a folder, all shared objects that are named "libtfkernel*" will be loaded. When the library is loaded, kernels registered in the library via the REGISTER_* macros are made available in the TensorFlow process.
 


 Args
  library_location   Path to the plugin or the folder of plugins. Relative or absolute filesystem path to a dynamic library file or folder.   
 


 Returns   None  

 


 Raises
  OSError   When the file to be loaded is not found.  
  RuntimeError   when unable to load the library.
tf.load_op_library     View source on GitHub    Loads a TensorFlow plugin, containing custom ops and kernels.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.load_op_library  
tf.load_op_library(
    library_filename
)
 Pass "library_filename" to a platform-specific mechanism for dynamically loading a library. The rules for determining the exact location of the library are platform-specific and are not documented here. When the library is loaded, ops and kernels registered in the library via the REGISTER_* macros are made available in the TensorFlow process. Note that ops with the same name as an existing op are rejected and not registered with the process.
 


 Args
  library_filename   Path to the plugin. Relative or absolute filesystem path to a dynamic library file.   
 


 Returns   A python module containing the Python wrappers for Ops defined in the plugin.  

 


 Raises
  RuntimeError   when unable to load the library or get the python wrappers.
Module: tf.lookup Public API for tf.lookup namespace. Modules experimental module: Public API for tf.lookup.experimental namespace. Classes class KeyValueTensorInitializer: Table initializers given keys and values tensors. class StaticHashTable: A generic hash table that is immutable once initialized. class StaticVocabularyTable: String to Id table that assigns out-of-vocabulary keys to hash buckets. class TextFileIndex: The key and value content to get from each line. class TextFileInitializer: Table initializers from a text file.
Module: tf.lookup.experimental Public API for tf.lookup.experimental namespace. Classes class DatasetInitializer: Creates a table initializer from a tf.data.Dataset. class DenseHashTable: A generic mutable hash table implementation using tensors as backing store.
tf.lookup.experimental.DatasetInitializer Creates a table initializer from a tf.data.Dataset.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.lookup.experimental.DatasetInitializer  
tf.lookup.experimental.DatasetInitializer(
    dataset
)
 Sample usage: 
keys = tf.data.Dataset.range(100)
values = tf.data.Dataset.range(100).map(
    lambda x: string_ops.as_string(x * 2))
ds = tf.data.Dataset.zip((keys, values))
init = tf.lookup.experimental.DatasetInitializer(ds)
table = tf.lookup.StaticHashTable(init, "")
table.lookup(tf.constant([0, 1, 2], dtype=tf.int64)).numpy()
array([b'0', b'2', b'4'], dtype=object)
 Raises: ValueError if dataset doesn't conform to specifications.
 


 Args
  dataset   A tf.data.Dataset object that produces tuples of scalars. The first scalar is treated as a key and the second as value.   
 


 Attributes
  dataset   A tf.data.Dataset object that produces tuples of scalars. The first scalar is treated as a key and the second as value.  
  key_dtype   The expected table key dtype.  
  value_dtype   The expected table value dtype.    Methods initialize View source 
initialize(
    table
)
 Returns the table initialization op.
tf.lookup.KeyValueTensorInitializer     View source on GitHub    Table initializers given keys and values tensors.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.lookup.KeyValueTensorInitializer  
tf.lookup.KeyValueTensorInitializer(
    keys, values, key_dtype=None, value_dtype=None, name=None
)
 
keys_tensor = tf.constant(['a', 'b', 'c'])
vals_tensor = tf.constant([7, 8, 9])
input_tensor = tf.constant(['a', 'f'])
init = tf.lookup.KeyValueTensorInitializer(keys_tensor, vals_tensor)
table = tf.lookup.StaticHashTable(
    init,
    default_value=-1)
table.lookup(input_tensor).numpy()
array([ 7, -1], dtype=int32)

 


 Args
  keys   The tensor for the keys.  
  values   The tensor for the values.  
  key_dtype   The keys data type. Used when keys is a python array.  
  value_dtype   The values data type. Used when values is a python array.  
  name   A name for the operation (optional).   
 


 Attributes
  key_dtype   The expected table key dtype.  
  value_dtype   The expected table value dtype.    Methods initialize View source 
initialize(
    table
)
 Initializes the given table with keys and values tensors.
 


 Args
  table   The table to initialize.   
 


 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.lookup.StaticHashTable     View source on GitHub    A generic hash table that is immutable once initialized. 
tf.lookup.StaticHashTable(
    initializer, default_value, name=None
)
 Example usage: 
keys_tensor = tf.constant(['a', 'b', 'c'])
vals_tensor = tf.constant([7, 8, 9])
input_tensor = tf.constant(['a', 'f'])
table = tf.lookup.StaticHashTable(
    tf.lookup.KeyValueTensorInitializer(keys_tensor, vals_tensor),
    default_value=-1)
table.lookup(input_tensor).numpy()
array([ 7, -1], dtype=int32)
 Or for more pythonic code: 
table[input_tensor].numpy()
array([ 7, -1], dtype=int32)
 The result of a lookup operation has the same shape as the argument: 
input_tensor = tf.constant([['a', 'b'], ['c', 'd']])
table[input_tensor].numpy()
array([[ 7,  8],
       [ 9, -1]], dtype=int32)

 


 Args
  initializer   The table initializer to use. See HashTable kernel for supported key and value types.  
  default_value   The value to use if a key is missing in the table.  
  name   A name for the operation (optional).   
 


 Attributes
  default_value   The default value of the table.  
  key_dtype   The table key dtype.  
  name   The name of the table.  
  resource_handle   Returns the resource handle associated with this Resource.  
  value_dtype   The table value dtype.    Methods export View source 
export(
    name=None
)
 Returns tensors of all keys and values in the table.
 


 Args
  name   A name for the operation (optional).   
 


 Returns   A pair of tensors with the first tensor containing all keys and the second tensors containing all values in the table.  
 lookup View source 
lookup(
    keys, name=None
)
 Looks up keys in a table, outputs the corresponding values. The default_value is used for keys not present in the table.
 


 Args
  keys   Keys to look up. May be either a SparseTensor or dense Tensor.  
  name   A name for the operation (optional).   
 


 Returns   A SparseTensor if keys are sparse, a RaggedTensor if keys are ragged, otherwise a dense Tensor.  

 


 Raises
  TypeError   when keys or default_value doesn't match the table data types.    size View source 
size(
    name=None
)
 Compute the number of elements in this table.
 


 Args
  name   A name for the operation (optional).   
 


 Returns   A scalar tensor containing the number of elements in this table.  
 __getitem__ View source 
__getitem__(
    keys
)
 Looks up keys in a table, outputs the corresponding values.
tf.lookup.TextFileIndex     View source on GitHub    The key and value content to get from each line.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.lookup.TextFileIndex  This class defines the key and value used for tf.lookup.TextFileInitializer. The key and value content to get from each line is specified either by the following, or a value >=0.  
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.
 


 Class Variables
  LINE_NUMBER   -1  
  WHOLE_LINE   -2
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.