keras-team/keras · error · ValueError
`HashedCrossing` should be called on at least two inputs. Re
Error message
`HashedCrossing` should be called on at least two inputs. Received: inputs={inputs} What it means
A crossing by definition needs at least two inputs; call() rejects lists with fewer than two elements.
Source
Thrown at keras/src/layers/preprocessing/hashed_crossing.py:196
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}"
)
if not all(tuple(x.shape) == first_shape for x in inputs[1:]):
raise ValueError(
"All `HashedCrossing` inputs should have equal shape. "
f"Received: inputs={inputs}"
)View on GitHub (pinned to 7a34a03db6)
Solutions
- Provide at least two tensors: layer([x, y])
- If you only have one feature, use layers.Hashing instead of HashedCrossing
Example fix
// before out = layer([x]) // after out = layer([x, y])
Defensive patterns
Strategy: validation
Validate before calling
assert len(inputs) >= 2, "HashedCrossing needs >= 2 inputs"
Type guard
def has_two_inputs(inputs):
return isinstance(inputs, (list, tuple)) and len(inputs) >= 2 Try / catch
catch ValueError from call() and either add a second input tensor or replace the layer with Hashing
Prevention
- Always supply at least two inputs to HashedCrossing
- A single input cannot be crossed; use Hashing or a lookup layer instead
When it happens
Trigger: layer([x]) — a one-element list — reaching _check_at_least_two_inputs during call().
Common situations: Passing a one-element list [x]; building a pipeline before the second feature is connected; copy-paste from a single-input layer.
Related errors
- Layer HashedCrossing requires TensorFlow. Install it via `pi
- `sparse=True` can only be used with the TensorFlow backend.
- Expected as input a list/tuple of 2 tensors. Received input_
- Expected the two input tensors to have identical shapes. Rec
- `HashedCrossing` should be called on a list or tuple of inpu
AI-assisted analysis of keras-team/keras@7a34a03db6 (2026-08-25).
Data as JSON: /api/errors/09ff83a6abdacd8c.
Report an issue: GitHub.