{"record":{"id":"c1c1bf88f513dcd8","repo":"keras-team/keras","slug":"all-hashedcrossing-inputs-should-have-an-integer","errorCode":null,"errorMessage":"All `HashedCrossing` inputs should have an integer or string dtype. Received: inputs={inputs}","messagePattern":"All `HashedCrossing` inputs should have an integer or string dtype\\. Received: inputs=(.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/preprocessing/hashed_crossing.py","lineNumber":226,"sourceCode":"                f\"Received: inputs={inputs}\"\n            )\n        if not all(tuple(x.shape) == first_shape for x in inputs[1:]):\n            raise ValueError(\n                \"All `HashedCrossing` inputs should have equal shape. \"\n                f\"Received: inputs={inputs}\"\n            )\n        if any(\n            isinstance(x, (tf.RaggedTensor, tf.SparseTensor)) for x in inputs\n        ):\n            raise ValueError(\n                \"All `HashedCrossing` inputs should be dense tensors. \"\n                f\"Received: inputs={inputs}\"\n            )\n        if not all(\n            tf.as_dtype(x.dtype).is_integer or x.dtype == tf.string\n            for x in inputs\n        ):\n            raise ValueError(\n                \"All `HashedCrossing` inputs should have an integer or \"\n                f\"string dtype. Received: inputs={inputs}\"\n            )\n","sourceCodeStart":208,"sourceCodeEnd":230,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/preprocessing/hashed_crossing.py#L208-L230","documentation":"Crossing works by hashing values, so inputs must be integers or strings. Float tensors (or other dtypes) are rejected because hashing floats is undefined in this layer.","triggerScenarios":"An input whose dtype is neither integer nor tf.string (e.g. float32) reaching the dtype check in _check_input_shape_and_type.","commonSituations":"Crossing float-encoded numeric features (normalized prices, log transforms); integer ids stored as float64 after pandas/numpy ops; passing embeddings or continuous columns.","solutions":["Cast floats to string: tf.strings.as_string(x)","Cast numeric codes to int: tf.cast(x, tf.int64)","Keep float features out of crossings or bucketize them (Discretization) into integer bins first"],"exampleFix":"// before\nout = layer([price_float, category_int])  # price is float32\n// after\nprice = tf.strings.as_string(price_float)\nout = layer([price, tf.cast(category_int, tf.int64)])","handlingStrategy":"validation","validationCode":"for i, x in enumerate(inputs):\n    if not (tf.as_dtype(x.dtype).is_integer or x.dtype == tf.string):\n        inputs[i] = tf.cast(x, tf.int64)  # or tf.strings.as_string(x)","typeGuard":"def int_or_string_dtype(inputs):\n    import tensorflow as tf\n    return all(tf.as_dtype(x.dtype).is_integer or x.dtype == tf.string for x in inputs)","tryCatchPattern":"catch ValueError from call() and cast offending inputs (tf.cast(x, tf.int64) or tf.strings.as_string(x)) before retrying","preventionTips":["Cast numeric features to a string or integer dtype before crossing","Keep crossed features as raw strings or integer ids, not floats"],"tags":["keras","hashed-crossing","dtype"],"backgroundTag":"dtype-mismatch","analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}