keras-team/keras · error · ValueError

Argument `name` must be a string and cannot contain characte

Error message

Argument `name` must be a string and cannot contain character `/`. Received: name={name}

What it means

Error "Argument `name` must be a string and cannot contain character `/`. Received: name={name}" thrown in keras-team/keras.

Source

Thrown at keras/src/backend/common/name_scope.py:22

class name_scope:
    """Creates a sub-namespace for variable paths.

    Args:
        name: Name of the current scope (string).
        caller: Optional ID of a caller object (e.g. class instance).
        deduplicate: If `True`, if `caller` was passed,
            and the previous caller matches the current caller,
            and the previous name matches the current name,
            do not reenter a new namespace.
        override_parent: Can be used to provide an absolute path
            which would override any previously opened name scopes.
    """

    def __init__(
        self, name, caller=None, deduplicate=True, override_parent=None
    ):
        if not isinstance(name, str) or "/" in name:
            raise ValueError(
                "Argument `name` must be a string and "
                "cannot contain character `/`. "
                f"Received: name={name}"
            )
        self.name = name
        self.caller = caller
        self.deduplicate = deduplicate
        self.override_parent = override_parent
        if (
            override_parent is None
            and deduplicate
            and getattr(caller, "_parent_path", None) is not None
        ):
            self.override_parent = caller._parent_path
        self._pop_on_exit = False

    def __enter__(self):
        name_scope_stack = global_state.get_global_attribute(

View on GitHub (pinned to 7a34a03db6)

When it happens

Trigger: Thrown at keras/src/backend/common/name_scope.py:22 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/790a4c8e6b1edeff. Report an issue: GitHub.