<h3 dir="auto">System information</h3>
<ul dir="auto">
<li>macOS 10.12.5</li>
<li>installed from binary</li>
<li>Tensorflow v1.2.0-1751-g43a819e13 1.2.1</li>
<li>Python 3.6.1</li>
<li>Bazel 0.5.2-homebrew</li>
</ul>
<h3 dir="auto">Describe the problem</h3>
<p dir="auto">The custom model section of the <a href="https://www.tensorflow.org/get_started/get_started" rel="nofollow">"Getting Started With TensorFlow" guide</a> doesn't define "eval_input_fn".</p>
<p dir="auto">I ran across the error when I copied the code line by line and ran it on my machine. I fixed it by adding the following definition after "input_fn" is defined:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="eval_input_fn = tf.contrib.learn.io.numpy_input_fn({&quot;x&quot;:x_eval}, y_eval,
                                                   4, num_epochs = 1000);"><pre class="notranslate"><code class="notranslate">eval_input_fn = tf.contrib.learn.io.numpy_input_fn({"x":x_eval}, y_eval,
                                                   4, num_epochs = 1000);
</code></pre></div>
<h3 dir="auto">Source code / logs</h3>
<p dir="auto">Code in Guide:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import numpy as np
import tensorflow as tf
# Declare list of features, we only have one real-valued feature
def model(features, labels, mode):
  # Build a linear model and predict values
  W = tf.get_variable(&quot;W&quot;, [1], dtype=tf.float64)
  b = tf.get_variable(&quot;b&quot;, [1], dtype=tf.float64)
  y = W*features['x'] + b
  # Loss sub-graph
  loss = tf.reduce_sum(tf.square(y - labels))
  # Training sub-graph
  global_step = tf.train.get_global_step()
  optimizer = tf.train.GradientDescentOptimizer(0.01)
  train = tf.group(optimizer.minimize(loss),
                   tf.assign_add(global_step, 1))
  # ModelFnOps connects subgraphs we built to the
  # appropriate functionality.
  return tf.contrib.learn.ModelFnOps(
      mode=mode, predictions=y,
      loss=loss,
      train_op=train)

estimator = tf.contrib.learn.Estimator(model_fn=model)
# define our data sets
x_train = np.array([1., 2., 3., 4.])
y_train = np.array([0., -1., -2., -3.])
x_eval = np.array([2., 5., 8., 1.])
y_eval = np.array([-1.01, -4.1, -7, 0.])
input_fn = tf.contrib.learn.io.numpy_input_fn({&quot;x&quot;: x_train}, y_train, 4, num_epochs=1000)

# WHERE I ADDED THE DEFINITION

# train
estimator.fit(input_fn=input_fn, steps=1000)
# Here we evaluate how well our model did. 
train_loss = estimator.evaluate(input_fn=input_fn)
eval_loss = estimator.evaluate(input_fn=eval_input_fn)
print(&quot;train loss: %r&quot;% train_loss)
print(&quot;eval loss: %r&quot;% eval_loss)"><pre class="notranslate"><code class="notranslate">import numpy as np
import tensorflow as tf
# Declare list of features, we only have one real-valued feature
def model(features, labels, mode):
  # Build a linear model and predict values
  W = tf.get_variable("W", [1], dtype=tf.float64)
  b = tf.get_variable("b", [1], dtype=tf.float64)
  y = W*features['x'] + b
  # Loss sub-graph
  loss = tf.reduce_sum(tf.square(y - labels))
  # Training sub-graph
  global_step = tf.train.get_global_step()
  optimizer = tf.train.GradientDescentOptimizer(0.01)
  train = tf.group(optimizer.minimize(loss),
                   tf.assign_add(global_step, 1))
  # ModelFnOps connects subgraphs we built to the
  # appropriate functionality.
  return tf.contrib.learn.ModelFnOps(
      mode=mode, predictions=y,
      loss=loss,
      train_op=train)

estimator = tf.contrib.learn.Estimator(model_fn=model)
# define our data sets
x_train = np.array([1., 2., 3., 4.])
y_train = np.array([0., -1., -2., -3.])
x_eval = np.array([2., 5., 8., 1.])
y_eval = np.array([-1.01, -4.1, -7, 0.])
input_fn = tf.contrib.learn.io.numpy_input_fn({"x": x_train}, y_train, 4, num_epochs=1000)

# WHERE I ADDED THE DEFINITION

# train
estimator.fit(input_fn=input_fn, steps=1000)
# Here we evaluate how well our model did. 
train_loss = estimator.evaluate(input_fn=input_fn)
eval_loss = estimator.evaluate(input_fn=eval_input_fn)
print("train loss: %r"% train_loss)
print("eval loss: %r"% eval_loss)
</code></pre></div>
<p dir="auto">Error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Traceback (most recent call last):
  File &quot;custom_model.py&quot;, line 37, in &lt;module&gt;
    eval_loss = estimator.evaluate(input_fn=eval_input_fn);
NameError: name 'eval_input_fn' is not defined"><pre class="notranslate"><code class="notranslate">Traceback (most recent call last):
  File "custom_model.py", line 37, in &lt;module&gt;
    eval_loss = estimator.evaluate(input_fn=eval_input_fn);
NameError: name 'eval_input_fn' is not defined
</code></pre></div>
<p dir="auto">Hello,</p>
<p dir="auto">I would like to submit that there is a programming bug on line 29 of the "custom model tutorial" within Getting Started with Tensorflow.</p>
<p dir="auto">The line should read:</p>
<p dir="auto">input_fn = tf.contrib.learn.io.numpy_input_fn({"x":x_train}, y_train, batch_size=4, num_epochs=1000)</p>
<p dir="auto">​Best regards.<br>
Jeff​</p>