且构网

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

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

更新时间:2023-12-02 18:25:04

完成预处理后,您可以通过调用 Input 的 tensor param 添加张量作为输入层

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))