keras-team/keras · error · ValueError

When specifying `crosses`, the argument `crossing_dim`…

Error message

When specifying `crosses`, the argument `crossing_dim` (dimensionality of the crossing space) should be specified as well.

What it means

FeatureSpace was constructed with crosses but without crossing_dim. Crossed features are hashed into a fixed-size space whose dimensionality must be declared (it cannot be inferred), so the constructor rejects a crosses list that has no accompanying crossing_dim.

Solutions

  1. Pass crossing_dim (e.g. crossing_dim=32) whenever crosses is non-empty
  2. Provide a crossing_dim inside each cross dict if specifying crosses as dicts
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at keras/src/layers/preprocessing/feature_space.py:417 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/1acb0af316bcd83b. Report an issue: GitHub.

Appendix: source

Thrown at keras/src/layers/preprocessing/feature_space.py:417

            raise ValueError("The `features` argument cannot be None or empty.")
        self.crossing_dim = crossing_dim
        self.hashing_dim = hashing_dim
        self.num_discretization_bins = num_discretization_bins
        self.features = {
            name: self._standardize_feature(name, value)
            for name, value in features.items()
        }
        self.crosses = []
        if crosses:
            feature_set = set(features.keys())
            for cross in crosses:
                if isinstance(cross, dict):
                    cross = serialization_lib.deserialize_keras_object(cross)
                if isinstance(cross, Cross):
                    self.crosses.append(cross)
                else:
                    if not crossing_dim:
                        raise ValueError(
                            "When specifying `crosses`, the argument "
                            "`crossing_dim` "
                            "(dimensionality of the crossing space) "
                            "should be specified as well."
                        )
                    for key in cross:
                        if key not in feature_set:
                            raise ValueError(
                                "All features referenced "
                                "in the `crosses` argument "
                                "should be present in the `features` dict. "
                                f"Received unknown features: {cross}"
                            )
                    self.crosses.append(Cross(cross, crossing_dim=crossing_dim))
        self.crosses_by_name = {cross.name: cross for cross in self.crosses}

        if output_mode not in {"dict", "concat"}:
            raise ValueError(

View on GitHub (pinned to 7a34a03db6)