keras-team/keras · error · ValueError

Invalid `summation_method` argument value "{summation_method

Error message

Invalid `summation_method` argument value "{summation_method}". Expected one of: {list(metrics_utils.AUCSummationMethod)}

What it means

Raised by keras.metrics.AUC's __init__ when summation_method is an AUCSummationMethod enum instance outside the supported members ('interpolation', 'minoring', 'majoring' and friends). As with curve, only enum instances hit this check; strings are validated elsewhere.

Source

Thrown at keras/src/metrics/confusion_metrics.py:1216

        num_labels=None,
        label_weights=None,
        from_logits=False,
    ):
        # Metric should be maximized during optimization.
        self._direction = "up"

        # Validate configurations.
        if isinstance(curve, metrics_utils.AUCCurve) and curve not in list(
            metrics_utils.AUCCurve
        ):
            raise ValueError(
                f'Invalid `curve` argument value "{curve}". '
                f"Expected one of: {list(metrics_utils.AUCCurve)}"
            )
        if isinstance(
            summation_method, metrics_utils.AUCSummationMethod
        ) and summation_method not in list(metrics_utils.AUCSummationMethod):
            raise ValueError(
                "Invalid `summation_method` "
                f'argument value "{summation_method}". '
                f"Expected one of: {list(metrics_utils.AUCSummationMethod)}"
            )

        # Update properties.
        self._init_from_thresholds = thresholds is not None
        if thresholds is not None:
            # If specified, use the supplied thresholds.
            self.num_thresholds = len(thresholds) + 2
            thresholds = sorted(thresholds)
            self._thresholds_distributed_evenly = (
                metrics_utils.is_evenly_distributed_thresholds(
                    np.array([0.0] + thresholds + [1.0])
                )
            )
        else:
            if num_thresholds <= 1:

View on GitHub (pinned to 7a34a03db6)

Solutions

  1. Use the string form: summation_method='interpolation'.
  2. Import the enum from the same Keras installation if enums are required.
  3. Avoid pickling enum objects inside training configs.

Example fix

# before
auc = keras.metrics.AUC(summation_method=old_tf_enum)

# after
auc = keras.metrics.AUC(summation_method='interpolation')
Defensive patterns

Strategy: validation

Validate before calling

assert summation_method in ('interpolation', 'minoring', 'majoring'), summation_method

Type guard

def is_valid_summation(v) -> bool:
    return v in ('interpolation', 'minoring', 'majoring')

Prevention

When it happens

Trigger: Passing an AUCSummationMethod enum from a different/older Keras or TF version, or a dynamically created enum instance, to keras.metrics.AUC(summation_method=...).

Common situations: Restored pickled configs across Keras upgrades; code copied between tensorflow.keras and standalone Keras.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of keras-team/keras@7a34a03db6 (2026-08-25). Data as JSON: /api/errors/aff907a8d680c195. Report an issue: GitHub.