1、TensorFlow2.x使用 keras.layers.experimental.preprocessing 的异常:
tensorflow.python.framework.errors_impl.InvalidArgumentError: assertion failed: [Input values must be in the range 0 <= values < max_tokens with max_tokens=3]
[[node model/category_encoding/Assert/Assert (defined at /work_place/python_project/tensorflow2Work/testModel/***.py:121) ]] [Op:__inference_train_function_1556]
原因:
have_kid_layer = tf.keras.layers.experimental.preprocessing.CategoryEncoding(max_tokens=4,output_mode="binary")(
tf.keras.layers.experimental.preprocessing.StringLookup(vocabulary=have_kid_voc,num_oov_indices=0,max_tokens=None)(have_kid)
)
解决:
have_kid_layer = tf.keras.layers.experimental.preprocessing.CategoryEncoding(max_tokens=8,output_mode="binary")(
tf.keras.layers.experimental.preproc