neulab/docprompting-conala huggingface dataset:
tf.keras.metrics.Hinge     View source on GitHub    Computes the hinge metric between y_true and y_pred. Inherits From: Mean, Metric, Layer, Module  View aliases  Main aliases 
tf.metrics.Hinge Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.metrics.Hinge  
tf.keras.metrics.Hinge(
    name='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.Hinge()
m.update_state([[0, 1], [0, 0]], [[0.6, 0.4], [0.4, 0.6]])
m.result().numpy()
1.3
 
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.1
 Usage with compile() API: model.compile(optimizer='sgd', loss='mse', metrics=[tf.keras.metrics.Hinge()])
 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.KLDivergence     View source on GitHub    Computes Kullback-Leibler divergence metric between y_true and y_pred. Inherits From: Mean, Metric, Layer, Module  View aliases  Main aliases 
tf.metrics.KLDivergence Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.metrics.KLDivergence  
tf.keras.metrics.KLDivergence(
    name='kullback_leibler_divergence', dtype=None
)
 metric = y_true * log(y_true / 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.KLDivergence()
m.update_state([[0, 1], [0, 0]], [[0.6, 0.4], [0.4, 0.6]])
m.result().numpy()
0.45814306
 
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()
0.9162892
 Usage with compile() API: model.compile(optimizer='sgd',
              loss='mse',
              metrics=[tf.keras.metrics.KLDivergence()])
 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.LogCoshError     View source on GitHub    Computes the logarithm of the hyperbolic cosine of the prediction error. Inherits From: Mean, Metric, Layer, Module  View aliases  Main aliases 
tf.metrics.LogCoshError Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.metrics.LogCoshError  
tf.keras.metrics.LogCoshError(
    name='logcosh', dtype=None
)
 logcosh = log((exp(x) + exp(-x))/2), where x is the error (y_pred - y_true)
 


 Args
  name   (Optional) string name of the metric instance.  
  dtype   (Optional) data type of the metric result.    Standalone usage: 
m = tf.keras.metrics.LogCoshError()
m.update_state([[0, 1], [0, 0]], [[1, 1], [0, 0]])
m.result().numpy()
0.10844523
 
m.reset_states()
m.update_state([[0, 1], [0, 0]], [[1, 1], [0, 0]],
               sample_weight=[1, 0])
m.result().numpy()
0.21689045
 Usage with compile() API: model.compile(optimizer='sgd',
              loss='mse',
              metrics=[tf.keras.metrics.LogCoshError()])
 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.Mean     View source on GitHub    Computes the (weighted) mean of the given values. Inherits From: Metric, Layer, Module  View aliases  Main aliases 
tf.metrics.Mean Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.metrics.Mean  
tf.keras.metrics.Mean(
    name='mean', dtype=None
)
 For example, if values is [1, 3, 5, 7] then the mean is 4. If the weights were specified as [1, 1, 0, 0] then the mean would be 2. This metric creates two variables, total and count that are used to compute the average of values. This average is ultimately returned as mean which is 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.Mean()
m.update_state([1, 3, 5, 7])
m.result().numpy()
4.0
m.reset_states()
m.update_state([1, 3, 5, 7], sample_weight=[1, 1, 0, 0])
m.result().numpy()
2.0
 Usage with compile() API: model.add_metric(tf.keras.metrics.Mean(name='mean_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.MeanAbsoluteError     View source on GitHub    Computes the mean absolute error between the labels and predictions. Inherits From: Mean, Metric, Layer, Module  View aliases  Main aliases 
tf.metrics.MeanAbsoluteError Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.metrics.MeanAbsoluteError  
tf.keras.metrics.MeanAbsoluteError(
    name='mean_absolute_error', dtype=None
)

 


 Args
  name   (Optional) string name of the metric instance.  
  dtype   (Optional) data type of the metric result.    Standalone usage: 
m = tf.keras.metrics.MeanAbsoluteError()
m.update_state([[0, 1], [0, 0]], [[1, 1], [0, 0]])
m.result().numpy()
0.25
 
m.reset_states()
m.update_state([[0, 1], [0, 0]], [[1, 1], [0, 0]],
               sample_weight=[1, 0])
m.result().numpy()
0.5
 Usage with compile() API: model.compile(
    optimizer='sgd',
    loss='mse',
    metrics=[tf.keras.metrics.MeanAbsoluteError()])
 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.MeanAbsolutePercentageError     View source on GitHub    Computes the mean absolute percentage error between y_true and y_pred. Inherits From: Mean, Metric, Layer, Module  View aliases  Main aliases 
tf.metrics.MeanAbsolutePercentageError Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.metrics.MeanAbsolutePercentageError  
tf.keras.metrics.MeanAbsolutePercentageError(
    name='mean_absolute_percentage_error', dtype=None
)

 


 Args
  name   (Optional) string name of the metric instance.  
  dtype   (Optional) data type of the metric result.    Standalone usage: 
m = tf.keras.metrics.MeanAbsolutePercentageError()
m.update_state([[0, 1], [0, 0]], [[1, 1], [0, 0]])
m.result().numpy()
250000000.0
 
m.reset_states()
m.update_state([[0, 1], [0, 0]], [[1, 1], [0, 0]],
               sample_weight=[1, 0])
m.result().numpy()
500000000.0
 Usage with compile() API: model.compile(
    optimizer='sgd',
    loss='mse',
    metrics=[tf.keras.metrics.MeanAbsolutePercentageError()])
 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.MeanIoU     View source on GitHub    Computes the mean Intersection-Over-Union metric. Inherits From: Metric, Layer, Module  View aliases  Main aliases 
tf.metrics.MeanIoU Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.metrics.MeanIoU  
tf.keras.metrics.MeanIoU(
    num_classes, name=None, dtype=None
)
 Mean Intersection-Over-Union is a common evaluation metric for semantic image segmentation, which first computes the IOU for each semantic class and then computes the average over classes. IOU is defined as follows: IOU = true_positive / (true_positive + false_positive + false_negative). The predictions are accumulated in a confusion matrix, weighted by sample_weight and the metric is then calculated from it. If sample_weight is None, weights default to 1. Use sample_weight of 0 to mask values.
 


 Args
  num_classes   The possible number of labels the prediction task can have. This value must be provided, since a confusion matrix of dimension = [num_classes, num_classes] will be allocated.  
  name   (Optional) string name of the metric instance.  
  dtype   (Optional) data type of the metric result.    Standalone usage: 
# cm = [[1, 1],
#        [1, 1]]
# sum_row = [2, 2], sum_col = [2, 2], true_positives = [1, 1]
# iou = true_positives / (sum_row + sum_col - true_positives))
# result = (1 / (2 + 2 - 1) + 1 / (2 + 2 - 1)) / 2 = 0.33
m = tf.keras.metrics.MeanIoU(num_classes=2)
m.update_state([0, 0, 1, 1], [0, 1, 0, 1])
m.result().numpy()
0.33333334
 
m.reset_states()
m.update_state([0, 0, 1, 1], [0, 1, 0, 1],
               sample_weight=[0.3, 0.3, 0.3, 0.1])
m.result().numpy()
0.23809525
 Usage with compile() API: model.compile(
  optimizer='sgd',
  loss='mse',
  metrics=[tf.keras.metrics.MeanIoU(num_classes=2)])
 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()
 Compute the mean intersection-over-union via the confusion matrix. update_state View source 
update_state(
    y_true, y_pred, sample_weight=None
)
 Accumulates the 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.MeanRelativeError     View source on GitHub    Computes the mean relative error by normalizing with the given values. Inherits From: Mean, Metric, Layer, Module  View aliases  Main aliases 
tf.metrics.MeanRelativeError Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.metrics.MeanRelativeError  
tf.keras.metrics.MeanRelativeError(
    normalizer, name=None, dtype=None
)
 This metric creates two local variables, total and count that are used to compute the mean relative error. This is weighted by sample_weight, and it is ultimately returned as mean_relative_error: 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
  normalizer   The normalizer values with same shape as predictions.  
  name   (Optional) string name of the metric instance.  
  dtype   (Optional) data type of the metric result.    Standalone usage: 
m = tf.keras.metrics.MeanRelativeError(normalizer=[1, 3, 2, 3])
m.update_state([1, 3, 2, 3], [2, 4, 6, 8])
 
# metric = mean(|y_pred - y_true| / normalizer)
#        = mean([1, 1, 4, 5] / [1, 3, 2, 3]) = mean([1, 1/3, 2, 5/3])
#        = 5/4 = 1.25
m.result().numpy()
1.25
 Usage with compile() API: model.compile(
  optimizer='sgd',
  loss='mse',
  metrics=[tf.keras.metrics.MeanRelativeError(normalizer=[1, 3])])
 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.
 


 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.MeanSquaredError     View source on GitHub    Computes the mean squared error between y_true and y_pred. Inherits From: Mean, Metric, Layer, Module  View aliases  Main aliases 
tf.metrics.MeanSquaredError Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.metrics.MeanSquaredError  
tf.keras.metrics.MeanSquaredError(
    name='mean_squared_error', dtype=None
)

 


 Args
  name   (Optional) string name of the metric instance.  
  dtype   (Optional) data type of the metric result.    Standalone usage: 
m = tf.keras.metrics.MeanSquaredError()
m.update_state([[0, 1], [0, 0]], [[1, 1], [0, 0]])
m.result().numpy()
0.25
 
m.reset_states()
m.update_state([[0, 1], [0, 0]], [[1, 1], [0, 0]],
               sample_weight=[1, 0])
m.result().numpy()
0.5
 Usage with compile() API: model.compile(
    optimizer='sgd',
    loss='mse',
    metrics=[tf.keras.metrics.MeanSquaredError()])
 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.MeanSquaredLogarithmicError     View source on GitHub    Computes the mean squared logarithmic error between y_true and y_pred. Inherits From: Mean, Metric, Layer, Module  View aliases  Main aliases 
tf.metrics.MeanSquaredLogarithmicError Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.metrics.MeanSquaredLogarithmicError  
tf.keras.metrics.MeanSquaredLogarithmicError(
    name='mean_squared_logarithmic_error', dtype=None
)

 


 Args
  name   (Optional) string name of the metric instance.  
  dtype   (Optional) data type of the metric result.    Standalone usage: 
m = tf.keras.metrics.MeanSquaredLogarithmicError()
m.update_state([[0, 1], [0, 0]], [[1, 1], [0, 0]])
m.result().numpy()
0.12011322
 
m.reset_states()
m.update_state([[0, 1], [0, 0]], [[1, 1], [0, 0]],
               sample_weight=[1, 0])
m.result().numpy()
0.24022643
 Usage with compile() API: model.compile(
    optimizer='sgd',
    loss='mse',
    metrics=[tf.keras.metrics.MeanSquaredLogarithmicError()])
 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.MeanTensor     View source on GitHub    Computes the element-wise (weighted) mean of the given tensors. Inherits From: Metric, Layer, Module  View aliases  Main aliases 
tf.metrics.MeanTensor Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.metrics.MeanTensor  
tf.keras.metrics.MeanTensor(
    name='mean_tensor', dtype=None
)
 MeanTensor returns a tensor with the same shape of the input tensors. The mean value is updated by keeping local variables total and count. The total tracks the sum of the weighted values, and count stores the sum of the weighted counts.
 


 Args
  name   (Optional) string name of the metric instance.  
  dtype   (Optional) data type of the metric result.    Standalone usage: 
m = tf.keras.metrics.MeanTensor()
m.update_state([0, 1, 2, 3])
m.update_state([4, 5, 6, 7])
m.result().numpy()
array([2., 3., 4., 5.], dtype=float32)
 
m.update_state([12, 10, 8, 6], sample_weight= [0, 0.2, 0.5, 1])
m.result().numpy()
array([2.       , 3.6363635, 4.8      , 5.3333335], dtype=float32)

 


 Attributes
  count  
 
  total  
   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 element-wise mean.
 


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


 Returns   Update op.