keras-team/keras · error · ValueError

Unsupported reduction

Error message

Unsupported reduction: {reduction}

What it means

Dispatch tail of the NumPy backend's `scatter_update`: it applies the optional `reduction` by branching over the recognized strings 'sum'/'add', 'max', 'min' and 'mul' (plus None for plain assignment). Any other `reduction` value falls through all branches to this generic guard, which rejects it as unsupported rather than defaulting to overwrite behavior.

Solutions

  1. Use one of the supported reduction strings: 'sum' (or 'add'), 'max', 'min', 'mul', or pass reduction=None for plain assignment
  2. Check for misspellings/casing (e.g. 'maximum' instead of 'max') when the value comes from config or user input
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at keras/src/backend/numpy/ops/core.py:355 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at keras/src/backend/numpy/ops/core.py:355

    return zeros


def scatter_update(inputs, indices, updates, reduction=None):
    indices = np.array(indices)
    indices = np.transpose(indices)
    idx = tuple(indices)
    if reduction is None:
        inputs[idx] = updates
    elif reduction == "add":
        np.add.at(inputs, idx, updates)
    elif reduction == "max":
        np.maximum.at(inputs, idx, updates)
    elif reduction == "min":
        np.minimum.at(inputs, idx, updates)
    elif reduction == "mul":
        np.multiply.at(inputs, idx, updates)
    else:
        raise ValueError(f"Unsupported reduction: {reduction}")
    return inputs


def slice(inputs, start_indices, shape):
    # Validate inputs
    if len(start_indices) != len(shape):
        raise ValueError(
            "Length of `start_indices` must match length of `shape`. "
            f"Received: start_indices={start_indices}, shape={shape}"
        )

    # Generate list of indices arrays for each dimension
    indices = [
        np.arange(start, start + length)
        for start, length in zip(start_indices, shape)
    ]

    # Use np.ix_ to create a multidimensional index array

View on GitHub (pinned to 7a34a03db6)