keras-team/keras · error · ValueError

`HashedCrossing` should be called on a list or tuple of inpu

Error message

`HashedCrossing` should be called on a list or tuple of inputs. Received: inputs={inputs}

What it means

HashedCrossing.call validates that inputs arrive as a list or tuple, since a crossing needs multiple named inputs. A bare tensor or dict cannot be crossed.

Source

Thrown at keras/src/layers/preprocessing/hashed_crossing.py:191

                depth=self.num_bins,
                sparse=self.sparse,
                dtype=self.compute_dtype,
                backend_module=tf_backend,
            )
            return backend_utils.convert_tf_tensor(outputs, dtype=self.dtype)

    def get_config(self):
        return {
            "num_bins": self.num_bins,
            "output_mode": self.output_mode,
            "sparse": self.sparse,
            "name": self.name,
            "dtype": self.dtype,
        }

    def _check_at_least_two_inputs(self, inputs):
        if not isinstance(inputs, (list, tuple)):
            raise ValueError(
                "`HashedCrossing` should be called on a list or tuple of "
                f"inputs. Received: inputs={inputs}"
            )
        if len(inputs) < 2:
            raise ValueError(
                "`HashedCrossing` should be called on at least two inputs. "
                f"Received: inputs={inputs}"
            )

    def _check_input_shape_and_type(self, inputs):
        first_shape = tuple(inputs[0].shape)
        rank = len(first_shape)
        if rank > 2 or (rank == 2 and first_shape[-1] != 1):
            raise ValueError(
                "All `HashedCrossing` inputs should have shape `()`, "
                "`(batch_size)` or `(batch_size, 1)`. "
                f"Received: inputs={inputs}"
            )

View on GitHub (pinned to 7a34a03db6)

Solutions

  1. Wrap inputs in a list: layer([x1, x2])
  2. With a dict of features, extract two values: layer([d['a'], d['b']])
  3. In Functional models, wire both Input nodes into the crossing layer

Example fix

// before
out = layer(feature_a)
// after
out = layer([feature_a, feature_b])
Defensive patterns

Strategy: type-guard

Validate before calling

assert isinstance(inputs, (list, tuple)), "HashedCrossing expects a list/tuple of inputs"

Type guard

def is_input_list(inputs):
    return isinstance(inputs, (list, tuple)) and len(inputs) >= 2

Try / catch

catch ValueError from call() and wrap inputs in a list if a bare tensor was passed

Prevention

When it happens

Trigger: layer(single_tensor) instead of layer([t1, t2]); passing a dict of features; splatting the wrong variable.

Common situations: Passing a single tensor directly: layer(x1); passing a dict of features; splatting the wrong variable.

Related errors


AI-assisted analysis of keras-team/keras@7a34a03db6 (2026-08-25). Data as JSON: /api/errors/95ae81ca8d381c45. Report an issue: GitHub.