title: Why Tensorflow error: `failed to convert object of type <class 'dict'> to Tensor` happens and How can I solve it?
body: <p>I am doing a task on traffic analysis and I am stymied with some error in my code. My data rows are like this:</p>
  
  <p><code>qurter | DOW (Day of week)| Hour | density | speed | label (predicted speed for another half an hour)</code></p>
  
  <p>The values are like this:</p>
  
  <pre><code>1, 6, 19, 23, 53.32, 45.23
  </code></pre>
  
  <p>Which means in some specific street during <code>1st</code> quarter of <code>19</code> o'clock on <code>Friday</code>, density of traffic is measured <code>23</code> and current speed is <code>53.32</code>. the predicted speed would be <code>45.23</code>. </p>
  
  <p>The task is to predict the speed for another half an hour by predictors given above.</p>
  
  <p>I am using this code to build a TensorFlow <code>DNNRegressor</code> for data:</p>
  
  <pre><code>import pandas as pd
  data = pd.read_csv('dataset.csv')
  X = data.iloc[:,:5].values
  y = data.iloc[:, 5].values
  from sklearn.model_selection import train_test_split
  
  X_train, X_test, y_train, y_test = train_test_split(X,y,test_size=0.2, random_state=0)
  
  from sklearn.preprocessing import MinMaxScaler
  scaler = MinMaxScaler()
  scaler.fit(X_train)
  
  X_train = pd.DataFrame(data=scaler.transform(X_train),columns =    ['quarter','DOW','hour','density','speed'])
  X_test = pd.DataFrame(data=scaler.transform(X_test),columns = ['quarter','DOW','hour','density','speed'])
  
  y_train = pd.DataFrame(data=y_train,columns = ['label'])
  y_test = pd.DataFrame(data=y_test,columns = ['label'])
  
  import tensorflow as tf
  
  speed = tf.feature_column.numeric_column('speed')
  hour = tf.feature_column.numeric_column('hour')
  density = tf.feature_column.numeric_column('density')
  quarter= tf.feature_column.numeric_column('quarter')
  DOW = tf.feature_column.numeric_column('DOW')
  
  feat_cols = [h_percentage, DOW, hour, density, speed]
  input_func = tf.estimator.inputs.pandas_input_fn(x=X_train,y=y_train ,batch_size=10,num_epochs=1000,shuffle=False)
  
  model = tf.estimator.DNNRegressor(hidden_units=[5,5,5],feature_columns=feat_cols)
  model.train(input_fn=input_func,steps=25000)
  predict_input_func = tf.estimator.inputs.pandas_input_fn(
    x=X_test,
    batch_size=10,
    num_epochs=1,
    shuffle=False)
  
  pred_gen = model.predict(predict_input_func)
  
  predictions = list(pred_gen)
  final_preds = []
  for pred in predictions:
      final_preds.append(pred['predictions'])
  
  from sklearn.metrics import mean_squared_error
  
  mean_squared_error(y_test,final_preds)**0.5
  </code></pre>
  
  <p>when I run this code, It throws an error with this ending:</p>
  
  <p><code>TypeError: Failed to convert object of type &lt;class 'dict'&gt; to Tensor. Contents: {'label': &lt;tf.Tensor 'fifo_queue_DequeueUpTo:6' shape=(?,) dtype=float64&gt;}. Consider casting elements to a supported type.
  </code>
  First of all what is the concept of error? I couldn't find source for reason of error to deal with it. And how can I modify code for solution?</p>
  
  <p>secondly does it improve the model performance to use tensorflow <code>categorical_column_with_identity</code> instead of <code>numeric_columns</code> for DOW which indicates days of week?</p>
  
  <p>I also want to know if it's useful to merge <code>quarter</code> and <code>hour</code> as a single column like <code>day time</code> (<code>quarter</code> is minutes in an hour which is going to be normalized between 0 and 1)?</p>