keras-team/keras · error · ValueError
Only `vocabulary_dtype='int64'` is supported at this time. R
Error message
Only `vocabulary_dtype='int64'` is supported at this time. Received: vocabulary_dtype={vocabulary_dtype} What it means
IntegerLookup currently supports only vocabulary_dtype='int64'. __init__ rejects any other dtype string because the underlying lookup tables are typed to int64 indices.
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)
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 great
- The value of `num_oov_indices` argument for `IntegerLookup`
- Unknown activation function '{activation}' cannot be seriali
- Could not interpret activation function identifier: {identif
- ConvNeXt does not support the `channels_first` image data fo
AI-assisted analysis of keras-team/keras@7a34a03db6 (2026-08-25).
Data as JSON: /api/errors/624bb00d1d74a691.
Report an issue: GitHub.