keras-team/keras · error · ValueError

Unsupported reduction: {reduction}

Error message

Unsupported reduction: {reduction}

What it means

Error "Unsupported reduction: {reduction}" thrown in keras-team/keras.

Source

Thrown at keras/src/backend/tensorflow/core.py:777

        # Use while_loop to handle both scalar and slice updates correctly
        num_updates = tf.shape(indices)[0]

        def body(i, result):
            idx = indices[i : i + 1]  # Shape (1, index_depth)
            current = tf.gather_nd(result, idx)  # Shape (1, *slice_shape)
            new_value = (
                current * updates[i]
            )  # Maintains shape (1, *slice_shape)
            return i + 1, tf.tensor_scatter_nd_update(result, idx, new_value)

        _, result = tf.while_loop(
            lambda i, _: i < num_updates,
            body,
            [0, inputs],
        )
        return result
    else:
        raise ValueError(f"Unsupported reduction: {reduction}")


def slice(inputs, start_indices, shape):
    return tf.slice(inputs, start_indices, shape)


def slice_update(inputs, start_indices, updates):
    return dynamic_update_slice(inputs, updates, start_indices)


def switch(index, branches, *operands):
    index = convert_to_tensor(index, "int32")
    index = tf.clip_by_value(index, 0, len(branches) - 1)

    # Workaround to deal with python closures. More details:
    # https://github.com/tensorflow/tensorflow/issues/8776#issuecomment-311383887
    def gen_fn(i):
        return lambda: branches[i](*operands)

View on GitHub (pinned to 7a34a03db6)

When it happens

Trigger: Thrown at keras/src/backend/tensorflow/core.py:777 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/608906eef2ecc8be. Report an issue: GitHub.