deepr.metrics package

Submodules

deepr.metrics.accuracy module

Accuracy metrics.

class deepr.metrics.accuracy.Accuracy(gold, pred, name)[source]

Bases: Metric

Accuracy.

class deepr.metrics.accuracy.AccuracyAtK(gold, logits, name, k)[source]

Bases: Metric

Accuracy at k.

deepr.metrics.base module

Base class for Metrics

class deepr.metrics.base.Metric[source]

Bases: ABC

Base class for Metrics

deepr.metrics.base.get_metric_variable(name, shape, dtype)[source]
Return type:

VariableV1

deepr.metrics.base.get_scalars(tensors, names=None, pattern=None)[source]

Retrieve scalars from tensors.

Parameters:
  • tensors (Dict[str, tf.Tensor]) – Dictionary

  • names (List[str], optional) – Tensor names

  • pattern (str, optional) – Pattern for re.match

Returns:

Return type:

Dict[str, tf.Tensor]

deepr.metrics.base.get_tensors(tensors, names=None, pattern=None)[source]

Extract tensors with names / pattern from tensors dictionary

Parameters:
  • tensors (Dict[str, tf.Tensor]) – Dictionary

  • names (List[str], optional) – Names in tensors

  • pattern (str, optional) – Pattern for re.match

Returns:

Return type:

Dict[str, tf.Tensor]

deepr.metrics.base.keep_scalars(tensors)[source]

Remove non-scalar tensors from tensors.

Parameters:

tensors (Dict[str, tf.Tensor]) – Dictionary

Return type:

Dict[str, Tensor]

deepr.metrics.base.sanitize_metric_name(name)[source]

Sanitize scope/variable name for tensorflow and mlflow

This is needed as sometimes variables automatically created while building layers contain forbidden characters >>> from tensorflow.python.framework.ops import _VALID_SCOPE_NAME_REGEX as TF_VALID_REGEX >>> from mlflow.utils.validation import _VALID_PARAM_AND_METRIC_NAMES as MLFLOW_VALID_REGEX >>> from deepr.metrics import sanitize_metric_name >>> kernel_variable_name = ‘my_layer/kernel:0’ >>> bool(TF_VALID_REGEX.match(kernel_variable_name)) False >>> bool(MLFLOW_VALID_REGEX.match(kernel_variable_name)) False >>> bool(TF_VALID_REGEX.match(sanitize_metric_name(kernel_variable_name))) True >>> bool(MLFLOW_VALID_REGEX.match(sanitize_metric_name(kernel_variable_name))) True

Return type:

str

deepr.metrics.core module

Last value metric

class deepr.metrics.core.LastValue(tensors=None, pattern=None)[source]

Bases: Metric

Last value Metric

class deepr.metrics.core.MaxValue(tensors=None, pattern=None)[source]

Bases: Metric

Max value Metric

deepr.metrics.core.max_value_metric(value, name)[source]

deepr.metrics.mean module

Mean Metrics

class deepr.metrics.mean.DecayMean(decay=0.99, tensors=None, pattern=None)[source]

Bases: Metric

Decay Mean Metric

class deepr.metrics.mean.FiniteMean(tensors=None, pattern=None)[source]

Bases: Metric

Finite Mean Metric

class deepr.metrics.mean.Mean(tensors=None, pattern=None)[source]

Bases: Metric

Finite Mean Metric

deepr.metrics.mean.decay_mean_metric(value, decay, name)[source]
deepr.metrics.mean.finite_mean_metric(value, name)[source]

Compute Mean Metric

deepr.metrics.step module

StepCounter Metric

class deepr.metrics.step.StepCounter(name)[source]

Bases: Metric

StepCounter Metric

deepr.metrics.variable module

Variable Value Metric.

class deepr.metrics.variable.VariableValue(name)[source]

Bases: Metric

Variable Value Metric.

Return value of variable created with tf.get_variable if the variable is a scalar. Otherwise, return the norm of that variable.

name

Variable name

Type:

str

Module contents