且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用Tensorflow张量设置Keras层的输入?

更新时间:2023-12-03 11:14:04

在完成预处理之后,可以通过调用Input

After you are done with pre-processing, You can add the tensor as input layer by calling tensor param of Input

所以在您的情况下:

tf_embedding_input = ...    # pre-processing output tensor

# Keras model
model = Sequential()
model.add(Input(tensor=tf_embedding_input)) 
model.add(Embedding(max_features, 128, input_length=maxlen))