I am new the tf, and the question maybe quite naive. I am trying to understand why the Test2 throughs error.
# Test 1
x = tf.constant([["aa,bbb,cc"], ["dd,,"]])
tf.strings.split(x, sep=',')
=> <tf.RaggedTensor [[[b'aa', b'bbb', b'cc']], [[b'dd', b'', b'']]]>
# Test2
x = tf.keras.layers.Input(shape=(1,), dtype=tf.string)
tf.strings.split(x, sep=",")
...
ValueError: Tensor conversion requested dtype int32 for Tensor with dtype int64: <tf.Tensor 'Cumsum:0' shape=(None,) dtype=int64>
IIUC, this should work as a simple model:
I am assuming your error is actually coming from a type mismatch after converting the strings to integers using a
StringLookup
orTextVectorization
layer, because this runs:Here is an example with a
TextVectorization
layer and aEmbedding
layer: