keras-team/keras · error · ValueError
Only `vocabulary_dtype='int64'` is supported at this time…
Error message
Only `vocabulary_dtype='int64'` is supported at this time. Received: vocabulary_dtype={vocabulary_dtype} What it means
IntegerLookup currently only implements vocabulary handling for the 'int64' vocabulary dtype. This ValueError fires at construction when `vocabulary_dtype` is set to anything other than 'int64' — other dtypes are unimplemented rather than invalid per se.
Solutions
- Omit vocabulary_dtype (default is int64)
- Cast your vocabulary array to int64: np.asarray(vocab, dtype='int64')
- If you need int32 output, cast after the layer: keras.ops.cast(layer(x), 'int32')
Example fix
// before layer = IntegerLookup(vocabulary_dtype='int32') // after layer = IntegerLookup() # int64 default; cast output later if needed
Defensive patterns
Strategy: validation
Validate before calling
assert vocabulary_dtype in (None, 'int64')
Prevention
- Omit vocabulary_dtype; cast outputs post-layer instead
When it happens
Trigger: Passing vocabulary_dtype='int32', 'float32', or anything other than 'int64' to keras.layers.IntegerLookup().
Common situations: Memory-optimization attempts to shrink vocabularies with int32; copying a config from another layer type that accepts dtype options; Keras 3 ports of older layers.
Related errors
- If `max_tokens` is set for `IntegerLookup`, it must be…
- The value of `num_oov_indices` argument for `IntegerLookup`…
- All `HashedCrossing` inputs should have an integer or…
- Argument `n` should be a positive integer. Received: n=
- Argument `size` should be a positive integer. Received…
AI-assisted analysis of keras-team/keras@7a34a03db6 (2026-08-25).
Data as JSON: /api/errors/624bb00d1d74a691.
Report an issue: GitHub.
Appendix: source
Thrown at keras/src/layers/preprocessing/integer_lookup.py:374
"Install it via `pip install tensorflow`."
)
if max_tokens is not None and max_tokens <= 1:
raise ValueError(
"If `max_tokens` is set for `IntegerLookup`, it must be "
f"greater than 1. Received: max_tokens={max_tokens}"
)
if num_oov_indices < 0:
raise ValueError(
"The value of `num_oov_indices` argument for `IntegerLookup` "
"must >= 0. Received: num_oov_indices="
f"{num_oov_indices}"
)
if sparse and backend.backend() != "tensorflow":
raise ValueError(
"`sparse=True` can only be used with the TensorFlow backend."
)
if vocabulary_dtype != "int64":
raise ValueError(
"Only `vocabulary_dtype='int64'` is supported "
"at this time. Received: "
f"vocabulary_dtype={vocabulary_dtype}"
)
super().__init__(
max_tokens=max_tokens,
num_oov_indices=num_oov_indices,
mask_token=mask_token,
oov_token=oov_token,
vocabulary=vocabulary,
vocabulary_dtype=vocabulary_dtype,
idf_weights=idf_weights,
invert=invert,
output_mode=output_mode,
sparse=sparse,
pad_to_max_tokens=pad_to_max_tokens,
oov_method=oov_method,
salt=salt,View on GitHub (pinned to 7a34a03db6)