keras-team/keras · error · ValueError
Invalid `curve` argument value "{curve}". Expected one of: {
Error message
Invalid `curve` argument value "{curve}". Expected one of: {list(metrics_utils.AUCCurve)} What it means
Raised by keras.metrics.AUC's __init__ when curve is an AUCCurve enum instance that is not a supported member (ROC or PR). This fires only when you pass an enum instance; plain strings are handled by a different code path.
Source
Thrown at keras/src/metrics/confusion_metrics.py:1209
num_thresholds=200,
curve="ROC",
summation_method="interpolation",
name=None,
dtype=None,
thresholds=None,
multi_label=False,
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)View on GitHub (pinned to 7a34a03db6)
Solutions
- Pass a string instead: curve='ROC' or curve='PR'.
- If enums are needed, import AUCCurve from the same Keras version's metrics_utils.
- Regenerate pickled/saved configs containing enum objects.
Example fix
# before
from keras.src.metrics import metrics_utils
auc = keras.metrics.AUC(curve=metrics_utils.AUCCurve('SQ'))
# after
auc = keras.metrics.AUC(curve='PR') Defensive patterns
Strategy: validation
Validate before calling
assert curve in ('ROC', 'PR'), f'curve must be ROC or PR, got {curve}' Type guard
def is_valid_curve(v) -> bool:
return v in ('ROC', 'PR') Prevention
- Pass strings, not enums, for serialization-friendly configs.
- Never pickle enum objects across version upgrades.
When it happens
Trigger: Passing a stale or custom AUCCurve enum member (e.g. pickled from an older TF/Keras version, or a dynamically constructed enum) to keras.metrics.AUC(curve=...).
Common situations: Code migrated from tensorflow.keras that persisted enum objects across versions; monkeypatched or dynamically created enum members.
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
- Invalid `summation_method` argument value "{summation_method
- Argument `num_thresholds` must be an integer > 1. Received:
- `num_labels` is needed only when `multi_label` is True.
- `y_pred` must have rank 2 when `multi_label=True`. Found ran
- Invalid AUC curve value: "{key}". Expected values are ["PR",
AI-assisted analysis of keras-team/keras@7a34a03db6 (2026-08-25).
Data as JSON: /api/errors/93acb8e0ffecb8f4.
Report an issue: GitHub.