neulab/docprompting-conala huggingface dataset:
tf.keras.metrics.Sum     View source on GitHub    Computes the (weighted) sum of the given values. Inherits From: Metric, Layer, Module  View aliases  Main aliases 
tf.metrics.Sum Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.metrics.Sum  
tf.keras.metrics.Sum(
    name='sum', dtype=None
)
 For example, if values is [1, 3, 5, 7] then the sum is 16. If the weights were specified as [1, 1, 0, 0] then the sum would be 4. This metric creates one variable, total, that is used to compute the sum of values. This is ultimately returned as sum. If sample_weight is None, weights default to 1. Use sample_weight of 0 to mask values.
 


 Args
  name   (Optional) string name of the metric instance.  
  dtype   (Optional) data type of the metric result.    Standalone usage: 
m = tf.keras.metrics.Sum()
m.update_state([1, 3, 5, 7])
m.result().numpy()
16.0
 Usage with compile() API: model.add_metric(tf.keras.metrics.Sum(name='sum_1')(outputs))
model.compile(optimizer='sgd', loss='mse')
 Methods reset_states View source 
reset_states()
 Resets all of the metric state variables. This function is called between epochs/steps, when a metric is evaluated during training. result View source 
result()
 Computes and returns the metric value tensor. Result computation is an idempotent operation that simply calculates the metric value using the state variables. update_state View source 
update_state(
    values, sample_weight=None
)
 Accumulates statistics for computing the metric.
 


 Args
  values   Per-example value.  
  sample_weight   Optional weighting of each example. Defaults to 1.   
 


 Returns   Update op.
tf.keras.metrics.TopKCategoricalAccuracy     View source on GitHub    Computes how often targets are in the top K predictions. Inherits From: Mean, Metric, Layer, Module  View aliases  Main aliases 
tf.metrics.TopKCategoricalAccuracy Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.metrics.TopKCategoricalAccuracy  
tf.keras.metrics.TopKCategoricalAccuracy(
    k=5, name='top_k_categorical_accuracy', dtype=None
)

 


 Args
  k   (Optional) Number of top elements to look at for computing accuracy. Defaults to 5.  
  name   (Optional) string name of the metric instance.  
  dtype   (Optional) data type of the metric result.    Standalone usage: 
m = tf.keras.metrics.TopKCategoricalAccuracy(k=1)
m.update_state([[0, 0, 1], [0, 1, 0]],
               [[0.1, 0.9, 0.8], [0.05, 0.95, 0]])
m.result().numpy()
0.5
 
m.reset_states()
m.update_state([[0, 0, 1], [0, 1, 0]],
               [[0.1, 0.9, 0.8], [0.05, 0.95, 0]],
               sample_weight=[0.7, 0.3])
m.result().numpy()
0.3
 Usage with compile() API: model.compile(optimizer='sgd',
              loss='mse',
              metrics=[tf.keras.metrics.TopKCategoricalAccuracy()])
 Methods reset_states View source 
reset_states()
 Resets all of the metric state variables. This function is called between epochs/steps, when a metric is evaluated during training. result View source 
result()
 Computes and returns the metric value tensor. Result computation is an idempotent operation that simply calculates the metric value using the state variables. update_state View source 
update_state(
    y_true, y_pred, sample_weight=None
)
 Accumulates metric statistics. y_true and y_pred should have the same shape.
 


 Args
  y_true   Ground truth values. shape = [batch_size, d0, .. dN].  
  y_pred   The predicted values. shape = [batch_size, d0, .. dN].  
  sample_weight   Optional sample_weight acts as a coefficient for the metric. If a scalar is provided, then the metric is simply scaled by the given value. If sample_weight is a tensor of size [batch_size], then the metric for each sample of the batch is rescaled by the corresponding element in the sample_weight vector. If the shape of sample_weight is [batch_size, d0, .. dN-1] (or can be broadcasted to this shape), then each metric element of y_pred is scaled by the corresponding value of sample_weight. (Note on dN-1: all metric functions reduce by 1 dimension, usually the last axis (-1)).   
 


 Returns   Update op.
tf.keras.metrics.top_k_categorical_accuracy     View source on GitHub    Computes how often targets are in the top K predictions.  View aliases  Main aliases 
tf.metrics.top_k_categorical_accuracy Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.metrics.top_k_categorical_accuracy  
tf.keras.metrics.top_k_categorical_accuracy(
    y_true, y_pred, k=5
)
 Standalone usage: 
y_true = [[0, 0, 1], [0, 1, 0]]
y_pred = [[0.1, 0.9, 0.8], [0.05, 0.95, 0]]
m = tf.keras.metrics.top_k_categorical_accuracy(y_true, y_pred, k=3)
assert m.shape == (2,)
m.numpy()
array([1., 1.], dtype=float32)

 


 Args
  y_true   The ground truth values.  
  y_pred   The prediction values.  
  k   (Optional) Number of top elements to look at for computing accuracy. Defaults to 5.   
 


 Returns   Top K categorical accuracy value.
tf.keras.metrics.TrueNegatives     View source on GitHub    Calculates the number of true negatives. Inherits From: Metric, Layer, Module  View aliases  Main aliases 
tf.metrics.TrueNegatives Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.metrics.TrueNegatives  
tf.keras.metrics.TrueNegatives(
    thresholds=None, name=None, dtype=None
)
 If sample_weight is given, calculates the sum of the weights of true negatives. This metric creates one local variable, accumulator that is used to keep track of the number of true negatives. If sample_weight is None, weights default to 1. Use sample_weight of 0 to mask values.
 


 Args
  thresholds   (Optional) Defaults to 0.5. A float value or a python list/tuple of float threshold values in [0, 1]. A threshold is compared with prediction values to determine the truth value of predictions (i.e., above the threshold is true, below is false). One metric value is generated for each threshold value.  
  name   (Optional) string name of the metric instance.  
  dtype   (Optional) data type of the metric result.    Standalone usage: 
m = tf.keras.metrics.TrueNegatives()
m.update_state([0, 1, 0, 0], [1, 1, 0, 0])
m.result().numpy()
2.0
 
m.reset_states()
m.update_state([0, 1, 0, 0], [1, 1, 0, 0], sample_weight=[0, 0, 1, 0])
m.result().numpy()
1.0
 Usage with compile() API: model.compile(optimizer='sgd',
              loss='mse',
              metrics=[tf.keras.metrics.TrueNegatives()])
 Methods reset_states View source 
reset_states()
 Resets all of the metric state variables. This function is called between epochs/steps, when a metric is evaluated during training. result View source 
result()
 Computes and returns the metric value tensor. Result computation is an idempotent operation that simply calculates the metric value using the state variables. update_state View source 
update_state(
    y_true, y_pred, sample_weight=None
)
 Accumulates the metric statistics.
 


 Args
  y_true   The ground truth values.  
  y_pred   The predicted values.  
  sample_weight   Optional weighting of each example. Defaults to 1. Can be a Tensor whose rank is either 0, or the same rank as y_true, and must be broadcastable to y_true.   
 


 Returns   Update op.
tf.keras.metrics.TruePositives     View source on GitHub    Calculates the number of true positives. Inherits From: Metric, Layer, Module  View aliases  Main aliases 
tf.metrics.TruePositives Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.metrics.TruePositives  
tf.keras.metrics.TruePositives(
    thresholds=None, name=None, dtype=None
)
 If sample_weight is given, calculates the sum of the weights of true positives. This metric creates one local variable, true_positives that is used to keep track of the number of true positives. If sample_weight is None, weights default to 1. Use sample_weight of 0 to mask values.
 


 Args
  thresholds   (Optional) Defaults to 0.5. A float value or a python list/tuple of float threshold values in [0, 1]. A threshold is compared with prediction values to determine the truth value of predictions (i.e., above the threshold is true, below is false). One metric value is generated for each threshold value.  
  name   (Optional) string name of the metric instance.  
  dtype   (Optional) data type of the metric result.    Standalone usage: 
m = tf.keras.metrics.TruePositives()
m.update_state([0, 1, 1, 1], [1, 0, 1, 1])
m.result().numpy()
2.0
 
m.reset_states()
m.update_state([0, 1, 1, 1], [1, 0, 1, 1], sample_weight=[0, 0, 1, 0])
m.result().numpy()
1.0
 Usage with compile() API: model.compile(optimizer='sgd',
              loss='mse',
              metrics=[tf.keras.metrics.TruePositives()])
 Methods reset_states View source 
reset_states()
 Resets all of the metric state variables. This function is called between epochs/steps, when a metric is evaluated during training. result View source 
result()
 Computes and returns the metric value tensor. Result computation is an idempotent operation that simply calculates the metric value using the state variables. update_state View source 
update_state(
    y_true, y_pred, sample_weight=None
)
 Accumulates the metric statistics.
 


 Args
  y_true   The ground truth values.  
  y_pred   The predicted values.  
  sample_weight   Optional weighting of each example. Defaults to 1. Can be a Tensor whose rank is either 0, or the same rank as y_true, and must be broadcastable to y_true.   
 


 Returns   Update op.
Module: tf.keras.mixed_precision Keras mixed precision API. See the mixed precision guide to learn how to use the API. Modules experimental module: Public API for tf.keras.mixed_precision.experimental namespace. Classes class LossScaleOptimizer: An optimizer that applies loss scaling to prevent numeric underflow. class Policy: A dtype policy for a Keras layer. Functions global_policy(...): Returns the global dtype policy. set_global_policy(...): Sets the global dtype policy.
Module: tf.keras.mixed_precision.experimental Public API for tf.keras.mixed_precision.experimental namespace. Classes class LossScaleOptimizer: An deprecated optimizer that applies loss scaling. class Policy: A deprecated dtype policy for a Keras layer. Functions get_layer_policy(...): Returns the dtype policy of a layer. global_policy(...): Returns the global dtype policy. set_policy(...): Sets the global dtype policy.
tf.keras.mixed_precision.experimental.get_layer_policy Returns the dtype policy of a layer. 
tf.keras.mixed_precision.experimental.get_layer_policy(
    layer
)
 Warning: This function is deprecated. Use tf.keras.layers.Layer.dtype_policy instead.
 


 Args
  layer   A tf.keras.layers.Layer.   
 


 Returns   The tf.keras.mixed_precision.Policy of the layer.
tf.keras.mixed_precision.global_policy Returns the global dtype policy.  View aliases  Main aliases 
tf.keras.mixed_precision.experimental.global_policy  
tf.keras.mixed_precision.global_policy()
 The global policy is the default tf.keras.mixed_precision.Policy used for layers, if no policy is passed to the layer constructor. If no policy has been set with keras.mixed_precision.set_global_policy, this will return a policy constructed from tf.keras.backend.floatx() (floatx defaults to float32). 
tf.keras.mixed_precision.global_policy()
<Policy "float32">
tf.keras.layers.Dense(10).dtype_policy  # Defaults to the global policy
<Policy "float32">
 If TensorFlow 2 behavior has been disabled with tf.compat.v1.disable_v2_behavior(), this will instead return a special "_infer" policy which infers the dtype from the dtype of the first input the first time the layer is called. This behavior matches the behavior that existed in TensorFlow 1. See tf.keras.mixed_precision.Policy for more information on policies.
 


 Returns   The global Policy.
tf.keras.mixed_precision.set_global_policy Sets the global dtype policy.  View aliases  Main aliases 
tf.keras.mixed_precision.experimental.set_policy  
tf.keras.mixed_precision.set_global_policy(
    policy
)
 The global policy is the default tf.keras.mixed_precision.Policy used for layers, if no policy is passed to the layer constructor. 
tf.keras.mixed_precision.set_global_policy('mixed_float16')
tf.keras.mixed_precision.global_policy()
<Policy "mixed_float16">
tf.keras.layers.Dense(10).dtype_policy
<Policy "mixed_float16">
# Global policy is not used if a policy is directly passed to constructor
tf.keras.layers.Dense(10, dtype='float64').dtype_policy
<Policy "float64">
tf.keras.mixed_precision.set_global_policy('float32')
 If no global policy is set, layers will instead default to a Policy constructed from tf.keras.backend.floatx(). To use mixed precision, the global policy should be set to 'mixed_float16' or 'mixed_bfloat16', so that every layer uses a 16-bit compute dtype and float32 variable dtype by default. Only floating point policies can be set as the global policy, such as 'float32' and 'mixed_float16'. Non-floating point policies such as 'int32' and 'complex64' cannot be set as the global policy because most layers do not support such policies. See tf.keras.mixed_precision.Policy for more information.
 


 Args
  policy   A Policy, or a string that will be converted to a Policy. Can also be None, in which case the global policy will be constructed from tf.keras.backend.floatx()
Module: tf.keras.models Code for model cloning, plus model-related API entries. 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 clone_model(...): Clone any Model instance. load_model(...): Loads a model saved via model.save(). model_from_config(...): Instantiates a Keras model from its config. model_from_json(...): Parses a JSON model configuration string and returns a model instance. model_from_yaml(...): Parses a yaml model configuration file and returns a model instance. save_model(...): Saves a model as a TensorFlow SavedModel or HDF5 file.
tf.keras.models.clone_model     View source on GitHub    Clone any Model instance.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.models.clone_model  
tf.keras.models.clone_model(
    model, input_tensors=None, clone_function=None
)
 Model cloning is similar to calling a model on new inputs, except that it creates new layers (and thus new weights) instead of sharing the weights of the existing layers.
 


 Arguments
  model   Instance of Model (could be a functional model or a Sequential model).  
  input_tensors   optional list of input tensors or InputLayer objects to build the model upon. If not provided, placeholders will be created.  
  clone_function   Callable to be used to clone each layer in the target model (except InputLayer instances). It takes as argument the layer instance to be cloned, and returns the corresponding layer instance to be used in the model copy. If unspecified, this callable defaults to the following serialization/deserialization function: lambda layer: layer.__class__.from_config(layer.get_config()). By passing a custom callable, you can customize your copy of the model, e.g. by wrapping certain layers of interest (you might want to replace all LSTM instances with equivalent Bidirectional(LSTM(...)) instances, for example).   
 


 Returns   An instance of Model reproducing the behavior of the original model, on top of new inputs tensors, using newly instantiated weights. The cloned model might behave differently from the original model if a custom clone_function modifies the layer.  

 


 Raises
  ValueError   in case of invalid model argument value.
tf.keras.models.load_model     View source on GitHub    Loads a model saved via model.save().  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.models.load_model  
tf.keras.models.load_model(
    filepath, custom_objects=None, compile=True, options=None
)
 Usage: 
model = tf.keras.Sequential([
    tf.keras.layers.Dense(5, input_shape=(3,)),
    tf.keras.layers.Softmax()])
model.save('/tmp/model')
loaded_model = tf.keras.models.load_model('/tmp/model')
x = tf.random.uniform((10, 3))
assert np.allclose(model.predict(x), loaded_model.predict(x))
 Note that the model weights may have different scoped names after being loaded. Scoped names include the model/layer names, such as "dense_1/kernel:0". It is recommended that you use the layer properties to access specific variables, e.g. model.get_layer("dense_1").kernel.
 


 Arguments
  filepath   One of the following:  String or pathlib.Path object, path to the saved model 
h5py.File object from which to load the model 

 
  custom_objects   Optional dictionary mapping names (strings) to custom classes or functions to be considered during deserialization.  
  compile   Boolean, whether to compile the model after loading.  
  options   Optional tf.saved_model.LoadOptions object that specifies options for loading from SavedModel.   
 


 Returns   A Keras model instance. If the original model was compiled, and saved with the optimizer, then the returned model will be compiled. Otherwise, the model will be left uncompiled. In the case that an uncompiled model is returned, a warning is displayed if the compile argument is set to True.  

 


 Raises
  ImportError   if loading from an hdf5 file and h5py is not available.  
  IOError   In case of an invalid savefile.
tf.keras.models.model_from_config     View source on GitHub    Instantiates a Keras model from its config.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.models.model_from_config  
tf.keras.models.model_from_config(
    config, custom_objects=None
)
 Usage: # for a Functional API model
tf.keras.Model().from_config(model.get_config())

# for a Sequential model
tf.keras.Sequential().from_config(model.get_config())

 


 Arguments
  config   Configuration dictionary.  
  custom_objects   Optional dictionary mapping names (strings) to custom classes or functions to be considered during deserialization.   
 


 Returns   A Keras model instance (uncompiled).  

 


 Raises
  TypeError   if config is not a dictionary.
tf.keras.models.model_from_json     View source on GitHub    Parses a JSON model configuration string and returns a model instance.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.models.model_from_json  
tf.keras.models.model_from_json(
    json_string, custom_objects=None
)
 Usage: 
model = tf.keras.Sequential([
    tf.keras.layers.Dense(5, input_shape=(3,)),
    tf.keras.layers.Softmax()])
config = model.to_json()
loaded_model = tf.keras.models.model_from_json(config)

 


 Arguments
  json_string   JSON string encoding a model configuration.  
  custom_objects   Optional dictionary mapping names (strings) to custom classes or functions to be considered during deserialization.   
 


 Returns   A Keras model instance (uncompiled).
tf.keras.models.model_from_yaml     View source on GitHub    Parses a yaml model configuration file and returns a model instance.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.models.model_from_yaml  
tf.keras.models.model_from_yaml(
    yaml_string, custom_objects=None
)
 Usage: 
model = tf.keras.Sequential([
    tf.keras.layers.Dense(5, input_shape=(3,)),
    tf.keras.layers.Softmax()])
try:
  import yaml
  config = model.to_yaml()
  loaded_model = tf.keras.models.model_from_yaml(config)
except ImportError:
  pass

 


 Arguments
  yaml_string   YAML string or open file encoding a model configuration.  
  custom_objects   Optional dictionary mapping names (strings) to custom classes or functions to be considered during deserialization.   
 


 Returns   A Keras model instance (uncompiled).  

 


 Raises
  ImportError   if yaml module is not found.
Module: tf.keras.optimizers Built-in optimizer classes.  View aliases  Main aliases 
tf.optimizers  For more examples see the base class tf.keras.optimizers.Optimizer. Modules schedules module: Public API for tf.keras.optimizers.schedules namespace. Classes class Adadelta: Optimizer that implements the Adadelta algorithm. class Adagrad: Optimizer that implements the Adagrad algorithm. class Adam: Optimizer that implements the Adam algorithm. class Adamax: Optimizer that implements the Adamax algorithm. class Ftrl: Optimizer that implements the FTRL algorithm. class Nadam: Optimizer that implements the NAdam algorithm. class Optimizer: Base class for Keras optimizers. class RMSprop: Optimizer that implements the RMSprop algorithm. class SGD: Gradient descent (with momentum) optimizer. Functions deserialize(...): Inverse of the serialize function. get(...): Retrieves a Keras Optimizer instance. serialize(...)
tf.keras.optimizers.Adadelta     View source on GitHub    Optimizer that implements the Adadelta algorithm. Inherits From: Optimizer  View aliases  Main aliases 
tf.optimizers.Adadelta Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.optimizers.Adadelta  
tf.keras.optimizers.Adadelta(
    learning_rate=0.001, rho=0.95, epsilon=1e-07, name='Adadelta',
    **kwargs
)
 Adadelta optimization is a stochastic gradient descent method that is based on adaptive learning rate per dimension to address two drawbacks:  The continual decay of learning rates throughout training The need for a manually selected global learning rate  Adadelta is a more robust extension of Adagrad that adapts learning rates based on a moving window of gradient updates, instead of accumulating all past gradients. This way, Adadelta continues learning even when many updates have been done. Compared to Adagrad, in the original version of Adadelta you don't have to set an initial learning rate. In this version, initial learning rate can be set, as in most other Keras optimizers. According to section 4.3 ("Effective Learning rates"), near the end of training step sizes converge to 1 which is effectively a high learning rate which would cause divergence. This occurs only near the end of the training as gradients and step sizes are small, and the epsilon constant in the numerator and denominator dominate past gradients and parameter updates which converge the learning rate to 1. According to section 4.4("Speech Data"),where a large neural network with 4 hidden layers was trained on a corpus of US English data, ADADELTA was used with 100 network replicas.The epsilon used is 1e-6 with rho=0.95 which converged faster than ADAGRAD, by the following construction: def init(self, lr=1.0, rho=0.95, epsilon=1e-6, decay=0., **kwargs):
 


 Args
  learning_rate   A Tensor, floating point value, or a schedule that is a tf.keras.optimizers.schedules.LearningRateSchedule. The learning rate. To match the exact form in the original paper use 1.0.  
  rho   A Tensor or a floating point value. The decay rate.  
  epsilon   A Tensor or a floating point value. A constant epsilon used to better conditioning the grad update.  
  name   Optional name prefix for the operations created when applying gradients. Defaults to "Adadelta".  
  **kwargs   Keyword arguments. Allowed to be one of "clipnorm" or "clipvalue". "clipnorm" (float) clips gradients by norm; "clipvalue" (float) clips gradients by value.    Reference:  Zeiler, 2012 
 


 Raises
  ValueError   in case of any invalid argument.