0
votes

I want to make some simple string operations within the keras model such that it can be end-to-end.

def get_model_para_pure():
    para = keras.Input(shape=(1, ), dtype="string", name='para') 
    para_lower = tf.strings.lower(para)
    shingles = tf.strings.split(para_lower)
    ...

however, it raises the error:

Tensor conversion requested dtype int32 for Tensor with dtype int64: <tf.Tensor 'Cumsum_5:0' shape=(None,) dtype=int64>

How can I implement these operations within a model.

1

1 Answers

-1
votes

Use tf.keras.layers.experimental.preprocessing.TextVectorization .

Read https://www.tensorflow.org/tutorials/structured_data/preprocessing_layers