neulab/docprompting-conala huggingface dataset:
tf.io.SparseFeature     View source on GitHub    Configuration for parsing a sparse input feature from an Example.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.SparseFeature, tf.compat.v1.io.SparseFeature  
tf.io.SparseFeature(
    index_key, value_key, dtype, size, already_sorted=False
)
 Note, preferably use VarLenFeature (possibly in combination with a SequenceExample) in order to parse out SparseTensors instead of SparseFeature due to its simplicity. Closely mimicking the SparseTensor that will be obtained by parsing an Example with a SparseFeature config, a SparseFeature contains a  value_key: The name of key for a Feature in the Example whose parsed Tensor will be the resulting SparseTensor.values. index_key: A list of names - one for each dimension in the resulting SparseTensor whose indices[i][dim] indicating the position of the i-th value in the dim dimension will be equal to the i-th value in the Feature with key named index_key[dim] in the Example. size: A list of ints for the resulting SparseTensor.dense_shape.  For example, we can represent the following 2D SparseTensor SparseTensor(indices=[[3, 1], [20, 0]],
             values=[0.5, -1.0]
             dense_shape=[100, 3])
 with an Example input proto features {
  feature { key: "val" value { float_list { value: [ 0.5, -1.0 ] } } }
  feature { key: "ix0" value { int64_list { value: [ 3, 20 ] } } }
  feature { key: "ix1" value { int64_list { value: [ 1, 0 ] } } }
}
 and SparseFeature config with 2 index_keys SparseFeature(index_key=["ix0", "ix1"],
              value_key="val",
              dtype=tf.float32,
              size=[100, 3])
 Fields:  
index_key: A single string name or a list of string names of index features. For each key the underlying feature's type must be int64 and its length must always match that of the value_key feature. To represent SparseTensors with a dense_shape of rank higher than 1 a list of length rank should be used. 
value_key: Name of value feature. The underlying feature's type must be dtype and its length must always match that of all the index_keys' features. 
dtype: Data type of the value_key feature. 
size: A Python int or list thereof specifying the dense shape. Should be a list if and only if index_key is a list. In that case the list must be equal to the length of index_key. Each for each entry i all values in the index_key[i] feature must be in [0, size[i]). 
already_sorted: A Python boolean to specify whether the values in value_key are already sorted by their index position. If so skip sorting. False by default (optional). 
 


 Attributes
  index_key  
 
  value_key  
 
  dtype  
 
  size  
 
  already_sorted
tf.io.TFRecordOptions     View source on GitHub    Options used for manipulating TFRecord files.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.io.TFRecordOptions, tf.compat.v1.python_io.TFRecordOptions  
tf.io.TFRecordOptions(
    compression_type=None, flush_mode=None, input_buffer_size=None,
    output_buffer_size=None, window_bits=None, compression_level=None,
    compression_method=None, mem_level=None, compression_strategy=None
)

 


 Args
  compression_type   "GZIP", "ZLIB", or "" (no compression).  
  flush_mode   flush mode or None, Default: Z_NO_FLUSH.  
  input_buffer_size   int or None.  
  output_buffer_size   int or None.  
  window_bits   int or None.  
  compression_level   0 to 9, or None.  
  compression_method   compression method or None.  
  mem_level   1 to 9, or None.  
  compression_strategy   strategy or None. Default: Z_DEFAULT_STRATEGY.   
 


 Raises
  ValueError   If compression_type is invalid.    Methods get_compression_type_string View source 
@classmethod
get_compression_type_string(
    options
)
 Convert various option types to a unified string.
 


 Args
  options   TFRecordOption, TFRecordCompressionType, or string.   
 


 Returns   Compression type as string (e.g. 'ZLIB', 'GZIP', or '').  

 


 Raises
  ValueError   If compression_type is invalid.   
 


 Class Variables
  compression_type_map
tf.io.TFRecordWriter     View source on GitHub    A class to write records to a TFRecords file.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.io.TFRecordWriter, tf.compat.v1.python_io.TFRecordWriter  
tf.io.TFRecordWriter(
    path, options=None
)
 TFRecords tutorial TFRecords is a binary format which is optimized for high throughput data retrieval, generally in conjunction with tf.data. TFRecordWriter is used to write serialized examples to a file for later consumption. The key steps are: Ahead of time:  Convert data into a serialized format 
Write the serialized data to one or more files During training or evaluation:
 Read serialized examples into memory Parse (deserialize) examples  A minimal example is given below: 
import tempfile
example_path = os.path.join(tempfile.gettempdir(), "example.tfrecords")
np.random.seed(0)
 
# Write the records to a file.
with tf.io.TFRecordWriter(example_path) as file_writer:
  for _ in range(4):
    x, y = np.random.random(), np.random.random()

    record_bytes = tf.train.Example(features=tf.train.Features(feature={
        "x": tf.train.Feature(float_list=tf.train.FloatList(value=[x])),
        "y": tf.train.Feature(float_list=tf.train.FloatList(value=[y])),
    })).SerializeToString()
    file_writer.write(record_bytes)
 
# Read the data back out.
def decode_fn(record_bytes):
  return tf.io.parse_single_example(
      # Data
      record_bytes,

      # Schema
      {"x": tf.io.FixedLenFeature([], dtype=tf.float32),
       "y": tf.io.FixedLenFeature([], dtype=tf.float32)}
  )
 
for batch in tf.data.TFRecordDataset([example_path]).map(decode_fn):
  print("x = {x:.4f},  y = {y:.4f}".format(**batch))
x = 0.5488,  y = 0.7152
x = 0.6028,  y = 0.5449
x = 0.4237,  y = 0.6459
x = 0.4376,  y = 0.8918
 This class implements __enter__ and __exit__, and can be used in with blocks like a normal file. (See the usage example above.)
 


 Args
  path   The path to the TFRecords file.  
  options   (optional) String specifying compression type, TFRecordCompressionType, or TFRecordOptions object.   
 


 Raises
  IOError   If path cannot be opened for writing.  
  ValueError   If valid compression_type can't be determined from options.    Methods close View source 
close()
 Close the file. flush View source 
flush()
 Flush the file. write View source 
write(
    record
)
 Write a string record to the file.
 


 Args
  record   str    __enter__ 
__enter__()
 enter(self: object) -> object __exit__ 
__exit__()
 exit(self: tensorflow.python._pywrap_record_io.RecordWriter, *args) -> None
tf.io.VarLenFeature     View source on GitHub    Configuration for parsing a variable-length input feature.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.VarLenFeature, tf.compat.v1.io.VarLenFeature  
tf.io.VarLenFeature(
    dtype
)
 Fields:  
dtype: Data type of input. 
 


 Attributes
  dtype
tf.io.write_file Writes contents to the file at input filename. Creates file and recursively  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.io.write_file, tf.compat.v1.write_file  
tf.io.write_file(
    filename, contents, name=None
)
 creates directory if not existing.
 


 Args
  filename   A Tensor of type string. scalar. The name of the file to which we write the contents.  
  contents   A Tensor of type string. scalar. The content to be written to the output file.  
  name   A name for the operation (optional).   
 


 Returns   The created Operation.
tf.io.write_graph     View source on GitHub    Writes a graph proto to a file.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.io.write_graph, tf.compat.v1.train.write_graph  
tf.io.write_graph(
    graph_or_graph_def, logdir, name, as_text=True
)
 The graph is written as a text proto unless as_text is False. v = tf.Variable(0, name='my_variable')
sess = tf.compat.v1.Session()
tf.io.write_graph(sess.graph_def, '/tmp/my-model', 'train.pbtxt')
 or v = tf.Variable(0, name='my_variable')
sess = tf.compat.v1.Session()
tf.io.write_graph(sess.graph, '/tmp/my-model', 'train.pbtxt')

 


 Args
  graph_or_graph_def   A Graph or a GraphDef protocol buffer.  
  logdir   Directory where to write the graph. This can refer to remote filesystems, such as Google Cloud Storage (GCS).  
  name   Filename for the graph.  
  as_text   If True, writes the graph as an ASCII proto.   
 


 Returns   The path of the output proto file.
tf.is_tensor     View source on GitHub    Checks whether x is a TF-native type that can be passed to many TF ops.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.is_tensor  
tf.is_tensor(
    x
)
 Use is_tensor to differentiate types that can ingested by TensorFlow ops without any conversion (e.g., tf.Tensor, tf.SparseTensor, and tf.RaggedTensor) from types that need to be converted into tensors before they are ingested (e.g., numpy ndarray and Python scalars). For example, in the following code block: if not tf.is_tensor(t):
  t = tf.convert_to_tensor(t)
return t.dtype
 we check to make sure that t is a tensor (and convert it if not) before accessing its shape and dtype.
 


 Args
  x   A python object to check.   
 


 Returns   True if x is a tensor or "tensor-like", False if not.
Module: tf.keras Implementation of the Keras API meant to be a high-level API for TensorFlow. Detailed documentation and user guides are available at tensorflow.org. Modules activations module: Built-in activation functions. applications module: Keras Applications are canned architectures with pre-trained weights. backend module: Keras backend API. callbacks module: Callbacks: utilities called at certain points during model training. constraints module: Constraints: functions that impose constraints on weight values. datasets module: Public API for tf.keras.datasets namespace. estimator module: Keras estimator API. experimental module: Public API for tf.keras.experimental namespace. initializers module: Keras initializer serialization / deserialization. layers module: Keras layers API. losses module: Built-in loss functions. metrics module: Built-in metrics. mixed_precision module: Keras mixed precision API. models module: Code for model cloning, plus model-related API entries. optimizers module: Built-in optimizer classes. preprocessing module: Keras data preprocessing utils. regularizers module: Built-in regularizers. utils module: Public API for tf.keras.utils namespace. wrappers module: Public API for tf.keras.wrappers namespace. Classes class Model: Model groups layers into an object with training and inference features. class Sequential: Sequential groups a linear stack of layers into a tf.keras.Model. Functions Input(...): Input() is used to instantiate a Keras tensor.
 


 Other Members
  version   '2.4.0'
Module: tf.keras.activations Built-in activation functions. Functions deserialize(...): Returns activation function given a string identifier. elu(...): Exponential Linear Unit. exponential(...): Exponential activation function. gelu(...): Applies the Gaussian error linear unit (GELU) activation function. get(...): Returns function. hard_sigmoid(...): Hard sigmoid activation function. linear(...): Linear activation function (pass-through). relu(...): Applies the rectified linear unit activation function. selu(...): Scaled Exponential Linear Unit (SELU). serialize(...): Returns the string identifier of an activation function. sigmoid(...): Sigmoid activation function, sigmoid(x) = 1 / (1 + exp(-x)). softmax(...): Softmax converts a real vector to a vector of categorical probabilities. softplus(...): Softplus activation function, softplus(x) = log(exp(x) + 1). softsign(...): Softsign activation function, softsign(x) = x / (abs(x) + 1). swish(...): Swish activation function, swish(x) = x * sigmoid(x). tanh(...): Hyperbolic tangent activation function.
tf.keras.activations.deserialize     View source on GitHub    Returns activation function given a string identifier.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.activations.deserialize  
tf.keras.activations.deserialize(
    name, custom_objects=None
)

 


 Args
  name   The name of the activation function.  
  custom_objects   Optional {function_name: function_obj} dictionary listing user-provided activation functions.   
 


 Returns   Corresponding activation function.  
 For example: 
tf.keras.activations.deserialize('linear')
 <function linear at 0x1239596a8>
tf.keras.activations.deserialize('sigmoid')
 <function sigmoid at 0x123959510>
tf.keras.activations.deserialize('abcd')
Traceback (most recent call last):

ValueError: Unknown activation function:abcd

 


 Raises
  ValueError   Unknown activation function if the input string does not denote any defined Tensorflow activation function.
tf.keras.activations.elu     View source on GitHub    Exponential Linear Unit.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.activations.elu  
tf.keras.activations.elu(
    x, alpha=1.0
)
 The exponential linear unit (ELU) with alpha > 0 is: x if x > 0 and alpha * (exp(x) - 1) if x < 0 The ELU hyperparameter alpha controls the value to which an ELU saturates for negative net inputs. ELUs diminish the vanishing gradient effect. ELUs have negative values which pushes the mean of the activations closer to zero. Mean activations that are closer to zero enable faster learning as they bring the gradient closer to the natural gradient. ELUs saturate to a negative value when the argument gets smaller. Saturation means a small derivative which decreases the variation and the information that is propagated to the next layer. Example Usage: 
import tensorflow as tf
model = tf.keras.Sequential()
model.add(tf.keras.layers.Conv2D(32, (3, 3), activation='elu',
         input_shape=(28, 28, 1)))
model.add(tf.keras.layers.MaxPooling2D((2, 2)))
model.add(tf.keras.layers.Conv2D(64, (3, 3), activation='elu'))
model.add(tf.keras.layers.MaxPooling2D((2, 2)))
model.add(tf.keras.layers.Conv2D(64, (3, 3), activation='elu'))
 
 


 Arguments
  x   Input tensor.  
  alpha   A scalar, slope of negative section. alpha controls the value to which an ELU saturates for negative net inputs.   
 


 Returns   The exponential linear unit (ELU) activation function: x if x > 0 and alpha * (exp(x) - 1) if x < 0.  
 Reference: Fast and Accurate Deep Network Learning by Exponential Linear Units (ELUs) (Clevert et al, 2016)
tf.keras.activations.exponential     View source on GitHub    Exponential activation function.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.activations.exponential  
tf.keras.activations.exponential(
    x
)
 For example: 
a = tf.constant([-3.0,-1.0, 0.0,1.0,3.0], dtype = tf.float32)
b = tf.keras.activations.exponential(a)
b.numpy()
array([0.04978707,  0.36787945,  1.,  2.7182817 , 20.085537], dtype=float32)

 


 Arguments
  x   Input tensor.   
 


 Returns   Tensor with exponential activation: exp(x).
tf.keras.activations.gelu Applies the Gaussian error linear unit (GELU) activation function. 
tf.keras.activations.gelu(
    x, approximate=False
)
 Gaussian error linear unit (GELU) computes x * P(X <= x), where P(X) ~ N(0, 1). The (GELU) nonlinearity weights inputs by their value, rather than gates inputs by their sign as in ReLU. For example: 
x = tf.constant([-3.0, -1.0, 0.0, 1.0, 3.0], dtype=tf.float32)
y = tf.keras.activations.gelu(x)
y.numpy()
array([-0.00404951, -0.15865529,  0.        ,  0.8413447 ,  2.9959507 ],
    dtype=float32)
y = tf.keras.activations.gelu(x, approximate=True)
y.numpy()
array([-0.00363752, -0.15880796,  0.        ,  0.841192  ,  2.9963627 ],
    dtype=float32)

 


 Arguments
  x   Input tensor.  
  approximate   A bool, whether to enable approximation.   
 


 Returns   The gaussian error linear activation: 0.5 * x * (1 + tanh(sqrt(2 / pi) * (x + 0.044715 * x^3))) if approximate is True or x * P(X <= x) = 0.5 * x * (1 + erf(x / sqrt(2))), where P(X) ~ N(0, 1), if approximate is False.  
 Reference:  Gaussian Error Linear Units (GELUs)
tf.keras.activations.get     View source on GitHub    Returns function.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.activations.get  
tf.keras.activations.get(
    identifier
)

 


 Arguments
  identifier   Function or string   
 


 Returns   Function corresponding to the input string or input function.  
 For example: 
tf.keras.activations.get('softmax')
 <function softmax at 0x1222a3d90>
tf.keras.activations.get(tf.keras.activations.softmax)
 <function softmax at 0x1222a3d90>
tf.keras.activations.get(None)
 <function linear at 0x1239596a8>
tf.keras.activations.get(abs)
 <built-in function abs>
tf.keras.activations.get('abcd')
Traceback (most recent call last):

ValueError: Unknown activation function:abcd

 


 Raises
  ValueError   Input is an unknown function or string, i.e., the input does not denote any defined function.
tf.keras.activations.hard_sigmoid     View source on GitHub    Hard sigmoid activation function.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.activations.hard_sigmoid  
tf.keras.activations.hard_sigmoid(
    x
)
 A faster approximation of the sigmoid activation. For example: 
a = tf.constant([-3.0,-1.0, 0.0,1.0,3.0], dtype = tf.float32)
b = tf.keras.activations.hard_sigmoid(a)
b.numpy()
array([0. , 0.3, 0.5, 0.7, 1. ], dtype=float32)

 


 Arguments
  x   Input tensor.   
 


 Returns   The hard sigmoid activation, defined as:  if x < -2.5: return 0 if x > 2.5: return 1 
if -2.5 <= x <= 2.5: return 0.2 * x + 0.5
tf.keras.activations.linear     View source on GitHub    Linear activation function (pass-through).  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.activations.linear  
tf.keras.activations.linear(
    x
)
 For example: 
a = tf.constant([-3.0,-1.0, 0.0,1.0,3.0], dtype = tf.float32)
b = tf.keras.activations.linear(a)
b.numpy()
array([-3., -1.,  0.,  1.,  3.], dtype=float32)

 


 Arguments
  x   Input tensor.   
 


 Returns   The input, unmodified.
tf.keras.activations.relu     View source on GitHub    Applies the rectified linear unit activation function.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.activations.relu  
tf.keras.activations.relu(
    x, alpha=0.0, max_value=None, threshold=0
)
 With default values, this returns the standard ReLU activation: max(x, 0), the element-wise maximum of 0 and the input tensor. Modifying default parameters allows you to use non-zero thresholds, change the max value of the activation, and to use a non-zero multiple of the input for values below the threshold. For example: 
foo = tf.constant([-10, -5, 0.0, 5, 10], dtype = tf.float32)
tf.keras.activations.relu(foo).numpy()
array([ 0.,  0.,  0.,  5., 10.], dtype=float32)
tf.keras.activations.relu(foo, alpha=0.5).numpy()
array([-5. , -2.5,  0. ,  5. , 10. ], dtype=float32)
tf.keras.activations.relu(foo, max_value=5).numpy()
array([0., 0., 0., 5., 5.], dtype=float32)
tf.keras.activations.relu(foo, threshold=5).numpy()
array([-0., -0.,  0.,  0., 10.], dtype=float32)

 


 Arguments
  x   Input tensor or variable.  
  alpha   A float that governs the slope for values lower than the threshold.  
  max_value   A float that sets the saturation threshold (the largest value the function will return).  
  threshold   A float giving the threshold value of the activation function below which values will be damped or set to zero.   
 


 Returns   A Tensor representing the input tensor, transformed by the relu activation function. Tensor will be of the same shape and dtype of input x.
tf.keras.activations.selu     View source on GitHub    Scaled Exponential Linear Unit (SELU).  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.activations.selu  
tf.keras.activations.selu(
    x
)
 The Scaled Exponential Linear Unit (SELU) activation function is defined as:  if x > 0: return scale * x if x < 0: return scale * alpha * (exp(x) - 1)  where alpha and scale are pre-defined constants (alpha=1.67326324 and scale=1.05070098). Basically, the SELU activation function multiplies scale (> 1) with the output of the tf.keras.activations.elu function to ensure a slope larger than one for positive inputs. The values of alpha and scale are chosen so that the mean and variance of the inputs are preserved between two consecutive layers as long as the weights are initialized correctly (see tf.keras.initializers.LecunNormal initializer) and the number of input units is "large enough" (see reference paper for more information). Example Usage: 
num_classes = 10  # 10-class problem
model = tf.keras.Sequential()
model.add(tf.keras.layers.Dense(64, kernel_initializer='lecun_normal',
                                activation='selu'))
model.add(tf.keras.layers.Dense(32, kernel_initializer='lecun_normal',
                                activation='selu'))
model.add(tf.keras.layers.Dense(16, kernel_initializer='lecun_normal',
                                activation='selu'))
model.add(tf.keras.layers.Dense(num_classes, activation='softmax'))

 


 Arguments
  x   A tensor or variable to compute the activation function for.   
 


 Returns   The scaled exponential unit activation: scale * elu(x, alpha).  
 Notes:  To be used together with the tf.keras.initializers.LecunNormal initializer. To be used together with the dropout variant tf.keras.layers.AlphaDropout (not regular dropout).  References:  Klambauer et al., 2017
tf.keras.activations.serialize     View source on GitHub    Returns the string identifier of an activation function.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.activations.serialize  
tf.keras.activations.serialize(
    activation
)

 


 Arguments
  activation   Function object.   
 


 Returns   String denoting the name attribute of the input function  
 For example: 
tf.keras.activations.serialize(tf.keras.activations.tanh)
'tanh'
tf.keras.activations.serialize(tf.keras.activations.sigmoid)
'sigmoid'
tf.keras.activations.serialize('abcd')
Traceback (most recent call last):

ValueError: ('Cannot serialize', 'abcd')

 


 Raises
  ValueError   The input function is not a valid one.
tf.keras.activations.sigmoid     View source on GitHub    Sigmoid activation function, sigmoid(x) = 1 / (1 + exp(-x)).  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.activations.sigmoid  
tf.keras.activations.sigmoid(
    x
)
 Applies the sigmoid activation function. For small values (<-5), sigmoid returns a value close to zero, and for large values (>5) the result of the function gets close to 1. Sigmoid is equivalent to a 2-element Softmax, where the second element is assumed to be zero. The sigmoid function always returns a value between 0 and 1. For example: 
a = tf.constant([-20, -1.0, 0.0, 1.0, 20], dtype = tf.float32)
b = tf.keras.activations.sigmoid(a)
b.numpy()
array([2.0611537e-09, 2.6894143e-01, 5.0000000e-01, 7.3105860e-01,
         1.0000000e+00], dtype=float32)

 


 Arguments
  x   Input tensor.   
 


 Returns   Tensor with the sigmoid activation: 1 / (1 + exp(-x)).