在我的previous question中,我使用Keras' Layer.set_input()
将我的Tensorflow预处理输出张量连接到我的Keras模型的输入 . 但是,在Keras版本 1.1.1
之后的this method has been removed .
如何在较新的Keras版本中实现这一目标?
Example:
# Tensorflow pre-processing
raw_input = tf.placeholder(tf.string)
### some TF operations on raw_input ###
tf_embedding_input = ... # pre-processing output tensor
# Keras model
model = Sequential()
e = Embedding(max_features, 128, input_length=maxlen)
### THIS DOESN'T WORK ANYMORE ###
e.set_input(tf_embedding_input)
################################
model.add(e)
model.add(LSTM(128, activation='sigmoid'))
model.add(Dense(num_classes, activation='softmax'))
1 回答
完成预处理后,可以通过调用
Input
的tensor
param将张量添加为输入层所以在你的情况下: