Metric wrappers and reduction metrics
Mean
Bases: Metric
Compute the mean of the given values.
For example, if values is [1, 3, 5, 7]
then the mean is 4.
This metric creates two variables, total
and count
.
The mean value returned is simply total
divided by count
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
(Optional) string name of the metric instance. |
'mean'
|
in_mask
|
list
|
(Optional) list of keys to keep to compute the metric. |
None
|
out_mask
|
list
|
(Optional) list of keys to remove to compute the metric. |
None
|
Example:
Source code in synalinks/src/metrics/reduction_metrics.py
MeanMetricWrapper
Bases: Mean
Wrap a stateless metric function with the Mean
metric.
You could use this class to quickly build a mean metric from a function. The
function needs to have the signature fn(y_true, y_pred)
and return a
per-sample reward array. MeanMetricWrapper.result()
will return
the average metric value across all samples seen so far.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fn
|
callable
|
The metric function to wrap, with signature
|
required |
name
|
str
|
(Optional) string name of the metric instance. |
None
|
in_mask
|
list
|
(Optional) list of keys to keep to compute the metric. |
None
|
out_mask
|
list
|
(Optional) list of keys to remove to compute the metric. |
None
|
**kwargs
|
keyword arguments
|
Keyword arguments to pass on to |
{}
|
Source code in synalinks/src/metrics/reduction_metrics.py
get_config()
Returns the serializable config of the metric.
Source code in synalinks/src/metrics/reduction_metrics.py
Sum
Bases: Metric
Compute the (weighted) sum of the given values.
For example, if values
is [1, 3, 5, 7]
then their sum is 16.
This metric creates one variable, total
.
This is ultimately returned as the sum value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
(Optional) string name of the metric instance. |
'sum'
|
in_mask
|
list
|
(Optional) list of keys to keep to compute the metric. |
None
|
out_mask
|
list
|
(Optional) list of keys to remove to compute the metric. |
None
|
Example: