title: tensorflow api 2.0 tensor objects are only iterable when eager execution is enabled. To iterate over this tensor use tf.map_fn
body: <p>I am trying to use tensorflow estimator using tensorflow api 2.</p>
  
  <pre><code>import tensorflow as tf
  import pandas as pd
  import numpy as np
  import matplotlib.pyplot as plt
  
  df = pd.DataFrame({'A': np.array([100, 105.4, 108.3, 111.1, 113, 114.7]),
                     'B': np.array([11, 11.8, 12.3, 12.8, 13.1,13.6]),
                     'C': np.array([55, 56.3, 57, 58, 59.5, 60.4]),
                     'Target': np.array([4000, 4200.34, 4700, 5300, 5800, 6400])})
  
  featcols = [
      tf.feature_column.numeric_column("A"),
      tf.feature_column.numeric_column("B"),
      tf.feature_column.numeric_column("C")
  ]
  
  model = tf.estimator.LinearRegressor(featcols)
  
  features = tf.convert_to_tensor(["A", "B", "C"])
  
  def train_input_fn():
      training_dataset = (
          tf.data.Dataset.from_tensor_slices(
              (
                  tf.cast(df[[features]].values, tf.float32),
                  tf.cast(df['Target'].values, tf.float32)
              )
          )
      )
      return training_dataset
  
  model.train(train_input_fn)
  </code></pre>
  
  <p>The last line throwes me:</p>
  
  <p><code>TypeError: Tensor objects are only iterable when eager execution is enabled. To iterate over this tensor use tf.map_fn</code></p>
  
  <p>Also, it gives me a warning:</p>
  
  <pre><code>Variable.initialized_value (from tensorflow.python.ops.variables) is deprecated and will be removed in a future version.
  Instructions for updating:
  Use Variable.read_value. Variables in 2.X are initialized automatically both in eager and graph (inside tf.defun) contexts.
  </code></pre>