neulab/docprompting-conala huggingface dataset:
tf.keras.metrics.Poisson     View source on GitHub    Computes the Poisson metric between y_true and y_pred. Inherits From: Mean, Metric, Layer, Module  View aliases  Main aliases 
tf.metrics.Poisson Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.metrics.Poisson  
tf.keras.metrics.Poisson(
    name='poisson', dtype=None
)
 metric = y_pred - y_true * log(y_pred)
 


 Args
  name   (Optional) string name of the metric instance.  
  dtype   (Optional) data type of the metric result.    Standalone usage: 
m = tf.keras.metrics.Poisson()
m.update_state([[0, 1], [0, 0]], [[1, 1], [0, 0]])
m.result().numpy()
0.49999997
 
m.reset_states()
m.update_state([[0, 1], [0, 0]], [[1, 1], [0, 0]],
               sample_weight=[1, 0])
m.result().numpy()
0.99999994
 Usage with compile() API: model.compile(optimizer='sgd',
              loss='mse',
              metrics=[tf.keras.metrics.Poisson()])
 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.PrecisionAtRecall Computes best precision where recall is >= specified value. Inherits From: Metric, Layer, Module  View aliases  Main aliases 
tf.metrics.PrecisionAtRecall Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.metrics.PrecisionAtRecall  
tf.keras.metrics.PrecisionAtRecall(
    recall, num_thresholds=200, name=None, dtype=None
)
 This metric creates four local variables, true_positives, true_negatives, false_positives and false_negatives that are used to compute the precision at the given recall. The threshold for the given recall value is computed and used to evaluate the corresponding precision. If sample_weight is None, weights default to 1. Use sample_weight of 0 to mask values.
 


 Args
  recall   A scalar value in range [0, 1].  
  num_thresholds   (Optional) Defaults to 200. The number of thresholds to use for matching the given recall.  
  name   (Optional) string name of the metric instance.  
  dtype   (Optional) data type of the metric result.    Standalone usage: 
m = tf.keras.metrics.PrecisionAtRecall(0.5)
m.update_state([0, 0, 0, 1, 1], [0, 0.3, 0.8, 0.3, 0.8])
m.result().numpy()
0.5
 
m.reset_states()
m.update_state([0, 0, 0, 1, 1], [0, 0.3, 0.8, 0.3, 0.8],
               sample_weight=[2, 2, 2, 1, 1])
m.result().numpy()
0.33333333
 Usage with compile() API: model.compile(
    optimizer='sgd',
    loss='mse',
    metrics=[tf.keras.metrics.PrecisionAtRecall(recall=0.8)])
 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 confusion matrix 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.RecallAtPrecision Computes best recall where precision is >= specified value. Inherits From: Metric, Layer, Module  View aliases  Main aliases 
tf.metrics.RecallAtPrecision Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.metrics.RecallAtPrecision  
tf.keras.metrics.RecallAtPrecision(
    precision, num_thresholds=200, name=None, dtype=None
)
 For a given score-label-distribution the required precision might not be achievable, in this case 0.0 is returned as recall. This metric creates four local variables, true_positives, true_negatives, false_positives and false_negatives that are used to compute the recall at the given precision. The threshold for the given precision value is computed and used to evaluate the corresponding recall. If sample_weight is None, weights default to 1. Use sample_weight of 0 to mask values.
 


 Args
  precision   A scalar value in range [0, 1].  
  num_thresholds   (Optional) Defaults to 200. The number of thresholds to use for matching the given precision.  
  name   (Optional) string name of the metric instance.  
  dtype   (Optional) data type of the metric result.    Standalone usage: 
m = tf.keras.metrics.RecallAtPrecision(0.8)
m.update_state([0, 0, 1, 1], [0, 0.5, 0.3, 0.9])
m.result().numpy()
0.5
 
m.reset_states()
m.update_state([0, 0, 1, 1], [0, 0.5, 0.3, 0.9],
               sample_weight=[1, 0, 0, 1])
m.result().numpy()
1.0
 Usage with compile() API: model.compile(
    optimizer='sgd',
    loss='mse',
    metrics=[tf.keras.metrics.RecallAtPrecision(precision=0.8)])
 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 confusion matrix 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.RootMeanSquaredError     View source on GitHub    Computes root mean squared error metric between y_true and y_pred. Inherits From: Mean, Metric, Layer, Module  View aliases  Main aliases 
tf.metrics.RootMeanSquaredError Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.metrics.RootMeanSquaredError  
tf.keras.metrics.RootMeanSquaredError(
    name='root_mean_squared_error', dtype=None
)
 Standalone usage: 
m = tf.keras.metrics.RootMeanSquaredError()
m.update_state([[0, 1], [0, 0]], [[1, 1], [0, 0]])
m.result().numpy()
0.5
 
m.reset_states()
m.update_state([[0, 1], [0, 0]], [[1, 1], [0, 0]],
               sample_weight=[1, 0])
m.result().numpy()
0.70710677
 Usage with compile() API: model.compile(
    optimizer='sgd',
    loss='mse',
    metrics=[tf.keras.metrics.RootMeanSquaredError()])
 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 root mean squared error 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.SensitivityAtSpecificity     View source on GitHub    Computes best sensitivity where specificity is >= specified value. Inherits From: Metric, Layer, Module  View aliases  Main aliases 
tf.metrics.SensitivityAtSpecificity Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.metrics.SensitivityAtSpecificity  
tf.keras.metrics.SensitivityAtSpecificity(
    specificity, num_thresholds=200, name=None, dtype=None
)
 the sensitivity at a given specificity. Sensitivity measures the proportion of actual positives that are correctly identified as such (tp / (tp + fn)). Specificity measures the proportion of actual negatives that are correctly identified as such (tn / (tn + fp)). This metric creates four local variables, true_positives, true_negatives, false_positives and false_negatives that are used to compute the sensitivity at the given specificity. The threshold for the given specificity value is computed and used to evaluate the corresponding sensitivity. If sample_weight is None, weights default to 1. Use sample_weight of 0 to mask values. For additional information about specificity and sensitivity, see the following.
 


 Args
  specificity   A scalar value in range [0, 1].  
  num_thresholds   (Optional) Defaults to 200. The number of thresholds to use for matching the given specificity.  
  name   (Optional) string name of the metric instance.  
  dtype   (Optional) data type of the metric result.    Standalone usage: 
m = tf.keras.metrics.SensitivityAtSpecificity(0.5)
m.update_state([0, 0, 0, 1, 1], [0, 0.3, 0.8, 0.3, 0.8])
m.result().numpy()
0.5
 
m.reset_states()
m.update_state([0, 0, 0, 1, 1], [0, 0.3, 0.8, 0.3, 0.8],
               sample_weight=[1, 1, 2, 2, 1])
m.result().numpy()
0.333333
 Usage with compile() API: model.compile(
    optimizer='sgd',
    loss='mse',
    metrics=[tf.keras.metrics.SensitivityAtSpecificity()])
 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 confusion matrix 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.serialize     View source on GitHub    Serializes metric function or Metric instance.  View aliases  Main aliases 
tf.metrics.serialize Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.metrics.serialize  
tf.keras.metrics.serialize(
    metric
)

 


 Arguments
  metric   A Keras Metric instance or a metric function.   
 


 Returns   Metric configuration dictionary.
tf.keras.metrics.SparseCategoricalAccuracy     View source on GitHub    Calculates how often predictions matches integer labels. Inherits From: Mean, Metric, Layer, Module  View aliases  Main aliases 
tf.metrics.SparseCategoricalAccuracy Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.metrics.SparseCategoricalAccuracy  
tf.keras.metrics.SparseCategoricalAccuracy(
    name='sparse_categorical_accuracy', dtype=None
)
 acc = np.dot(sample_weight, np.equal(y_true, np.argmax(y_pred, axis=1))
 You can provide logits of classes as y_pred, since argmax of logits and probabilities are same. This metric creates two local variables, total and count that are used to compute the frequency with which y_pred matches y_true. This frequency is ultimately returned as sparse categorical accuracy: an idempotent operation that simply divides total by count. 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.SparseCategoricalAccuracy()
m.update_state([[2], [1]], [[0.1, 0.6, 0.3], [0.05, 0.95, 0]])
m.result().numpy()
0.5
 
m.reset_states()
m.update_state([[2], [1]], [[0.1, 0.6, 0.3], [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.SparseCategoricalAccuracy()])
 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.SparseTopKCategoricalAccuracy     View source on GitHub    Computes how often integer targets are in the top K predictions. Inherits From: Mean, Metric, Layer, Module  View aliases  Main aliases 
tf.metrics.SparseTopKCategoricalAccuracy Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.metrics.SparseTopKCategoricalAccuracy  
tf.keras.metrics.SparseTopKCategoricalAccuracy(
    k=5, name='sparse_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.SparseTopKCategoricalAccuracy(k=1)
m.update_state([2, 1], [[0.1, 0.9, 0.8], [0.05, 0.95, 0]])
m.result().numpy()
0.5
 
m.reset_states()
m.update_state([2, 1], [[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.SparseTopKCategoricalAccuracy()])
 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.sparse_categorical_accuracy     View source on GitHub    Calculates how often predictions matches integer labels.  View aliases  Main aliases 
tf.metrics.sparse_categorical_accuracy Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.metrics.sparse_categorical_accuracy  
tf.keras.metrics.sparse_categorical_accuracy(
    y_true, y_pred
)
 Standalone usage: 
y_true = [2, 1]
y_pred = [[0.1, 0.9, 0.8], [0.05, 0.95, 0]]
m = tf.keras.metrics.sparse_categorical_accuracy(y_true, y_pred)
assert m.shape == (2,)
m.numpy()
array([0., 1.], dtype=float32)
 You can provide logits of classes as y_pred, since argmax of logits and probabilities are same.
 


 Args
  y_true   Integer ground truth values.  
  y_pred   The prediction values.   
 


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

 


 Args
  y_true   tensor of true targets.  
  y_pred   tensor of predicted targets.  
  k   (Optional) Number of top elements to look at for computing accuracy. Defaults to 5.   
 


 Returns   Sparse top K categorical accuracy value.
tf.keras.metrics.SpecificityAtSensitivity     View source on GitHub    Computes best specificity where sensitivity is >= specified value. Inherits From: Metric, Layer, Module  View aliases  Main aliases 
tf.metrics.SpecificityAtSensitivity Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.metrics.SpecificityAtSensitivity  
tf.keras.metrics.SpecificityAtSensitivity(
    sensitivity, num_thresholds=200, name=None, dtype=None
)
 Sensitivity measures the proportion of actual positives that are correctly identified as such (tp / (tp + fn)). Specificity measures the proportion of actual negatives that are correctly identified as such (tn / (tn + fp)). This metric creates four local variables, true_positives, true_negatives, false_positives and false_negatives that are used to compute the specificity at the given sensitivity. The threshold for the given sensitivity value is computed and used to evaluate the corresponding specificity. If sample_weight is None, weights default to 1. Use sample_weight of 0 to mask values. For additional information about specificity and sensitivity, see the following.
 


 Args
  sensitivity   A scalar value in range [0, 1].  
  num_thresholds   (Optional) Defaults to 200. The number of thresholds to use for matching the given sensitivity.  
  name   (Optional) string name of the metric instance.  
  dtype   (Optional) data type of the metric result.    Standalone usage: 
m = tf.keras.metrics.SpecificityAtSensitivity(0.5)
m.update_state([0, 0, 0, 1, 1], [0, 0.3, 0.8, 0.3, 0.8])
m.result().numpy()
0.66666667
 
m.reset_states()
m.update_state([0, 0, 0, 1, 1], [0, 0.3, 0.8, 0.3, 0.8],
               sample_weight=[1, 1, 2, 2, 2])
m.result().numpy()
0.5
 Usage with compile() API: model.compile(
    optimizer='sgd',
    loss='mse',
    metrics=[tf.keras.metrics.SpecificityAtSensitivity()])
 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 confusion matrix 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.SquaredHinge     View source on GitHub    Computes the squared hinge metric between y_true and y_pred. Inherits From: Mean, Metric, Layer, Module  View aliases  Main aliases 
tf.metrics.SquaredHinge Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.metrics.SquaredHinge  
tf.keras.metrics.SquaredHinge(
    name='squared_hinge', dtype=None
)
 y_true values are expected to be -1 or 1. If binary (0 or 1) labels are provided we will convert them to -1 or 1.
 


 Args
  name   (Optional) string name of the metric instance.  
  dtype   (Optional) data type of the metric result.    Standalone usage: 
m = tf.keras.metrics.SquaredHinge()
m.update_state([[0, 1], [0, 0]], [[0.6, 0.4], [0.4, 0.6]])
m.result().numpy()
1.86
 
m.reset_states()
m.update_state([[0, 1], [0, 0]], [[0.6, 0.4], [0.4, 0.6]],
               sample_weight=[1, 0])
m.result().numpy()
1.46
 Usage with compile() API: model.compile(
    optimizer='sgd',
    loss='mse',
    metrics=[tf.keras.metrics.SquaredHinge()])
 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.