Search code examples
pythontensorflowkeraseager

Tensorflow v1.4: Layer.input not supported in Eager mode


I understand that Eager mode is a new alpha feature on the nightly builds and that it is not perfect yet, but I do not know if there are any tf.keras workarounds for this problem.

The error Layer.input not supported in Eager mode. triggers on the block

model = tf.keras.models.Sequential()
model.add(tf.layers.Dense(2, input_shape = (None, 1)))
model.add(tf.layers.Dense(units = 1))
model.compile(optimizer = "sgd", loss = "mean_squared_error")

I do not know anything about keras or the keras tensorflow API and I was wondering if there was a way to avoid Layer.input with keras techniques so as to stay within Eager mode. Following a tutorial in the tf.Eager docs I have confirmed that model = tf.layers.Dense(1) works but I don't know how to add another layer.

Any help is very much appreciated.

EDIT As of tensorflow v1.10, keras is supported in eager mode.


Solution

  • Keras Models are not yet supported with eager execution, but Keras layers are. Which means that while you can't use tf.keras.models.Sequential yet, you could combine layers yourself. See the user guide.

    Hope that helps.