keras-team/keras · error · ValueError

Cannot pass None at locations

Error message

Cannot pass None at locations {none_args} with signature={signature}

What it means

Guard in the vectorize wrapper: None was passed for argument positions whose signature declares non-empty core dimensions. A None carries no shape, so its core dims cannot be parsed; the vectorization machinery only tolerates None where the signature expects a scalar '()'.

Solutions

  1. Pass a real tensor (e.g. zeros of the right shape) instead of None at those positions.
  2. Add those argument indices to excluded so they bypass signature parsing.
  3. Declare '()' core dims for optional arguments and handle None inside the wrapped function.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at keras/src/backend/common/backend_utils.py:624 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/21667705c6f7b619. Report an issue: GitHub.

Appendix: source

Thrown at keras/src/backend/common/backend_utils.py:624

    @functools.wraps(pyfunc)
    def wrapped(*args, **kwargs):
        excluded_func, args, kwargs = _vectorize_apply_excluded(
            pyfunc, excluded, args, kwargs
        )

        if signature is not None:
            input_core_dims, output_core_dims = (
                _vectorize_parse_gufunc_signature(signature)
            )
        else:
            input_core_dims = [()] * len(args)
            output_core_dims = None

        none_args = {i for i, arg in enumerate(args) if arg is None}
        if any(none_args):
            if any(input_core_dims[i] != () for i in none_args):
                raise ValueError(
                    f"Cannot pass None at locations {none_args} "
                    f"with signature={signature}"
                )
            excluded_func, args, _ = _vectorize_apply_excluded(
                excluded_func, none_args, args, {}
            )
            input_core_dims = [
                dim
                for i, dim in enumerate(input_core_dims)
                if i not in none_args
            ]

        args = tuple(map(ops.convert_to_tensor, args))

        broadcast_shape, dim_sizes = _vectorize_parse_input_dimensions(
            args, input_core_dims
        )
        checked_func = _vectorize_check_output_dims(

View on GitHub (pinned to 7a34a03db6)