Keras Forward Pass With Tensorflow Variable As Input
I am trying to use a Keras network (A) within another Keras network (B). I train network A first. Then I'm using it in network B to perform some regularization. Inside network B I
Solution 1:
I found my answer in a keras blog post. https://blog.keras.io/keras-as-a-simplified-interface-to-tensorflow-tutorial.html
from keras.models import Sequential
model = Sequential()
model.add(Dense(32, activation='relu', input_dim=784))
model.add(Dense(10, activation='softmax'))
# this works!
x = tf.placeholder(tf.float32, shape=(None, 784))
y = model(x)
Solution 2:
I am not sure where the tensorflow variable is coming in, but if it is there, you can do this:
model.predict([sess.run(x)])
where sess
is the tensorflow session, i.e. sess = tf.Session()
.
Post a Comment for "Keras Forward Pass With Tensorflow Variable As Input"