Reputation: 1080
In my previous question, I used Keras' Layer.set_input()
to connect my Tensorflow pre-processing output tensor to my Keras model's input. However, this method has been removed after Keras version 1.1.1
.
How can I achieve this in newer Keras versions?
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'))
Upvotes: 21
Views: 19196
Reputation: 9099
After you are done with pre-processing, You can add the tensor as input layer by calling tensor
param of Input
So in your case:
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))
Upvotes: 17