{"record":{"id":"56b5342126c15fb3","repo":"keras-team/keras","slug":"invalid-reduction-reduction-supported-values-a","errorCode":null,"errorMessage":"Invalid reduction: {reduction}. Supported values are: None, 'add', 'max', 'min', 'mul'.","messagePattern":"Invalid reduction: (.+?)\\. Supported values are: None, 'add', 'max', 'min', 'mul'\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/ops/core.py","lineNumber":417,"sourceCode":"            `\"mul\"`: Updates are multiplied with existing values.\n\n    Returns:\n        A tensor, has the same shape and dtype as `inputs`.\n\n    Example:\n\n    Using `reduction=\"add\"` to accumulate values at the same index:\n\n    >>> inputs = np.zeros((4,))\n    >>> indices = [[0], [0], [1]]\n    >>> updates = np.array([1., 1., 1.])\n    >>> keras.ops.scatter_update(inputs, indices, updates, reduction=\"add\")\n    array([2., 1., 0., 0.])\n    \"\"\"\n    if reduction is not None:\n        reduction = reduction.lower()\n        if reduction not in (\"add\", \"max\", \"min\", \"mul\"):\n            raise ValueError(\n                f\"Invalid reduction: {reduction}. \"\n                \"Supported values are: None, 'add', 'max', 'min', 'mul'.\"\n            )\n    if any_symbolic_tensors((inputs, indices, updates)):\n        return ScatterUpdate(reduction=reduction).symbolic_call(\n            inputs, indices, updates\n        )\n    return backend.core.scatter_update(\n        inputs, indices, updates, reduction=reduction\n    )\n\n\nclass Slice(Operation):\n    def __init__(self, shape, *, name=None):\n        super().__init__(name=name)\n        self.shape = shape\n\n    def call(self, inputs, start_indices):","sourceCodeStart":399,"sourceCodeEnd":435,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/ops/core.py#L399-L435","documentation":"scatter_update supports only a fixed set of reduction modes when merging duplicate indices: 'add', 'max', 'min', 'mul' (or None for overwrite). Anything else, after lowercasing, raises.","triggerScenarios":"keras.ops.scatter_update(x, idx, upd, reduction='sum') or reduction='mean'","commonSituations":"Typing 'mean', 'sum', or 'avg' out of habit from other scatter APIs (torch scatter, jax)","solutions":["Use one of 'add', 'max', 'min', 'mul' or None","For 'sum' semantics use 'add'","For mean reduction, scatter_add then divide by counts manually"],"exampleFix":"# before\nkeras.ops.scatter_update(x, idx, upd, reduction='sum')\n\n# after\nkeras.ops.scatter_update(x, idx, upd, reduction='add')","handlingStrategy":"validation","validationCode":"assert reduction in (None, 'add', 'max', 'min', 'mul')","typeGuard":null,"tryCatchPattern":"try:\n    keras.ops.scatter_update(x, i, u, reduction=r)\nexcept ValueError:\n    keras.ops.scatter_update(x, i, u)","preventionTips":["Use only None/'add'/'max'/'min'/'mul' (case-insensitive) for reduction"],"tags":["keras","ops","scatter-update","reduction"],"backgroundTag":"invalid-argument-value","analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}