在我的 上一个问题,我用过Keras' Layer.set_input()
将我的Tensorflow预处理输出张量连接到我的Keras模型的输入。然而, 此方法已被删除 在Keras版本之后 1.1.1
。
如何在较新的Keras版本中实现这一目标?
例:
# 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'))