yanachen
yanachen

Reputation: 3753

Processing string input in tensorflow model

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.

Upvotes: 1

Views: 1174

Answers (1)

DachuanZhao
DachuanZhao

Reputation: 1339

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

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

Upvotes: -1

Related Questions