title: Minimal DNNRegressor example with TensorFlow
body: <p>I'm new to Python and TensorFlow and I'm trying to build a simple working example with fake data in TensorFlow. My goal is to use the DNNRegressor estimator to predict a real value from a multidimensional input. This is the code I wrote:</p>
  
  <pre class="lang-py prettyprint-override"><code>import pandas as pd
  import tensorflow as tf
  import numpy as np
  
  # Amount of train samples
  m_train = 1000
  # Amount of test samples
  m_test = 100
  # Dimensions for each sample
  n = 10
  
  def from_dataset(ds):
     return lambda: ds.make_one_shot_iterator().get_next()
  
  # Create random samples with numpy
  train_data = (np.random.sample((m_train,n)), np.random.sample((m_train,1)))
  test_data = (np.random.sample((m_test,n)), np.random.sample((m_test,1)))
  
  # Create two datasets, one for trainning and the other for testing
  train_dataset = tf.data.Dataset.from_tensor_slices(train_data)
  test_dataset = tf.data.Dataset.from_tensor_slices(test_data)
  
  feature_columns = [tf.contrib.layers.real_valued_column("", dimension=n)]
  
  model = tf.estimator.DNNRegressor(hidden_units=[20, 20], feature_columns=feature_columns)
  
  # Train the model
  model.train(input_fn=from_dataset(train_dataset), steps=1000)
  
  # Evaluate the unseen samples
  eval_result = model.evaluate(input_fn=from_dataset(test_dataset))
  </code></pre>
  
  <p>And this is the error I get:</p>
  
  <pre><code>$ python fake.py 
  WARNING:tensorflow:Using temporary folder as model directory: /tmp/tmp1j5irF
  Traceback (most recent call last):
    File "fake.py", line 28, in &lt;module&gt;
      model.train(input_fn=from_dataset(train_dataset), steps=1000)
    File "/usr/lib/python2.7/site-packages/tensorflow/python/estimator/estimator.py", line 314, in train
      loss = self._train_model(input_fn, hooks, saving_listeners)
    File "/usr/lib/python2.7/site-packages/tensorflow/python/estimator/estimator.py", line 743, in _train_model
      features, labels, model_fn_lib.ModeKeys.TRAIN, self.config)
    File "/usr/lib/python2.7/site-packages/tensorflow/python/estimator/estimator.py", line 725, in _call_model_fn
      model_fn_results = self._model_fn(features=features, **kwargs)
    File "/usr/lib/python2.7/site-packages/tensorflow/python/estimator/canned/dnn.py", line 448, in _model_fn
      config=config)
    File "/usr/lib/python2.7/site-packages/tensorflow/python/estimator/canned/dnn.py", line 153, in _dnn_model_fn
      'Given type: {}'.format(type(features)))
  ValueError: features should be a dictionary of `Tensor`s. Given type: &lt;class 'tensorflow.python.framework.ops.Tensor'&gt;
  </code></pre>
  
  <p>I supose I have to use a dictionary of Tensors, but I'm just beginning in Python and I don't know how to do it.</p>