Skip to content

IntegerLookup raises expected OOV validation error when num_oov_indices=0 and inputs contain unknown tokens #22521

@tosubmitissue

Description

@tosubmitissue

Summary

keras.layers.IntegerLookup correctly errors in eager mode when num_oov_indices=0 and the input contains values outside the vocabulary. This reproduction does not appear to show a bug; it matches the documented behavior.

Reproduction

import keras
import numpy as np

layer = keras.layers.IntegerLookup(
    vocabulary=list(range(100)),
    num_oov_indices=0,
    mask_token=-1,
)

x = np.array([[12, 1138, 42], [42, 1000, 36]])
layer(x)

Expected result

An error indicating that inputs must all be in-vocabulary when num_oov_indices=0.

Actual result

An exception is raised:

When num_oov_indices=0 all inputs should be in vocabulary, found OOV values [1138 1000]

Notes

The symbolic keras.Input(...) path still builds and returns output shape (None, 3) as expected.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions