title: Tensorflow: Keras, Estimators and custom input function
body: <p>TF1.4 made Keras an integral part. 
  When trying to create Estimators from Keras models with propratery input function (I.e., not using the tf.estimator.inputs.numpy_input_fn) things are not working as Tensorflow can not fuse the model with the Input function.</p>
  
  <p>I am using tf.keras.estimator.model_to_estimator</p>
  
  <pre><code>keras_estimator = tf.keras.estimator.model_to_estimator(
              keras_model = keras_model,
              config = run_config)
  
  train_spec = tf.estimator.TrainSpec(input_fn=train_input_fn, 
                                      max_steps=self.train_steps)
  eval_spec = tf.estimator.EvalSpec(input_fn=eval_input_fn,
                                    steps=None)
  
  tf.estimator.train_and_evaluate(keras_estimator, train_spec, eval_spec)
  </code></pre>
  
  <p>and I get the following error message:</p>
  
  <pre><code>    Cannot find %s with name "%s" in Keras Model. It needs to match '
                'one of the following:
  </code></pre>
  
  <p>I found some reference for this topic <a href="https://www.tensorflow.org/versions/master/programmers_guide/estimators" rel="nofollow noreferrer">here</a> (strangely enough its hidden in the TF docs in the master branch - compare to <a href="https://www.tensorflow.org/programmers_guide/estimators" rel="nofollow noreferrer">this</a>)</p>
  
  <p>If you have the same issue - see my answer below. Might save you several hours. </p>