title: Could not find trained model in model_dir
body: <p>I have been going through Google's Machine Learning Crash Course, and am at the "First steps with TensorFlow" section. I wanted to run the examples on my machine, and keep getting an error that says: </p>
  
  <pre><code>ValueError: Could not find trained model in model_dir: C:\Users\Username\AppData
  \Local\Temp\tmpowu7j37s. 
  </code></pre>
  
  <p>The folder at the end is different every time I run the script. So it's creating a directory for model_dir, but then puts nothing there, or puts my model there and it is deleted by the time the <code>predict()</code> method is called. 
  If I try to define model_dir in the estimator.LinearRegressor init method and set the checkpoint_path of the <code>predict()</code> method to the same directory, it tells me access is denied no matter where I point, in C or to C:\Users, etc. 
  I should also mention I am executing inside an Anaconda environment.
  Any help is greatly appreciated!</p>
  
  <pre><code>import math
  
  from IPython import display
  from matplotlib import cm
  from matplotlib import gridspec
  from matplotlib import pyplot as plt
  import numpy as np
  import pandas as pd
  from sklearn import metrics
  import tensorflow as tf
  from tensorflow.python.data import Dataset
  
  tf.logging.set_verbosity(tf.logging.ERROR)
  pd.options.display.max_rows = 10
  pd.options.display.float_format = '{:.1f}'.format
  
  #LOAD Dataset
  california_housing_dataframe = pd.read_csv("california_housing_train.csv", sep=",")
  
  #Randomize data (to avoid ordering bias) and div a clumn by 1000 to get to a learning rate we usually work with
  california_housing_dataframe = california_housing_dataframe.reindex(
      np.random.permutation(california_housing_dataframe.index))
  california_housing_dataframe["median_house_value"] /= 1000.0
  print(california_housing_dataframe) #print top and botton 5 rows (see max rows 10 above)
  
  #examine data briefly
  print(california_housing_dataframe.describe())
  #________________________________________________________________________________________
  # Define the input feature: total_rooms.
  my_feature = california_housing_dataframe[["total_rooms"]]
  
  # Configure a numeric feature column for total_rooms.
  feature_columns = [tf.feature_column.numeric_column("total_rooms")]
  
  # Define the label.
  targets = california_housing_dataframe["median_house_value"]
  
  #__________________________________________________________________________________________
  
  # Use gradient descent as the optimizer for training the model.
  my_optimizer=tf.train.GradientDescentOptimizer(learning_rate=0.0000001)
  my_optimizer = tf.contrib.estimator.clip_gradients_by_norm(my_optimizer, 5.0)
  
  # Configure the linear regression model with our feature columns and optimizer.
  # Set a learning rate of 0.0000001 for Gradient Descent.
  linear_regressor = tf.estimator.LinearRegressor(
      feature_columns=feature_columns,
      optimizer=my_optimizer
  )
  
  #______________________________________________________________________________________________
  
  def my_input_fn(features, targets, batch_size=1, shuffle=True, num_epochs=None):
      """Trains a linear regression model of one feature.
  
      Args:
        features: pandas DataFrame of features
        targets: pandas DataFrame of targets
        batch_size: Size of batches to be passed to the model
        shuffle: True or False. Whether to shuffle the data.
        num_epochs: Number of epochs for which data should be repeated. None = repeat indefinitely
      Returns:
        Tuple of (features, labels) for next data batch
      """
  
      # Convert pandas data into a dict of np arrays.
      features = {key:np.array(value) for key,value in dict(features).items()}                                           
  
      # Construct a dataset, and configure batching/repeating
      ds = Dataset.from_tensor_slices((features,targets)) # warning: 2GB limit
      ds = ds.batch(batch_size).repeat(num_epochs)
  
      # Shuffle the data, if specified
      if shuffle:
        ds = ds.shuffle(buffer_size=10000)
  
      # Return the next batch of data
      features, labels = ds.make_one_shot_iterator().get_next()
      return features, labels
  
      #_______________________________________________________________________________________________
  
      _ = linear_regressor.train(
      input_fn = lambda:my_input_fn(my_feature, targets),
      steps=100
  )
  
      #__________________________________________________________________________________________________
  
  print(linear_regressor.model_dir)
  
  # Create an input function for predictions.
  # Note: Since we're making just one prediction for each example, we don't 
  # need to repeat or shuffle the data here.
  prediction_input_fn =lambda: my_input_fn(my_feature, targets, num_epochs=1, shuffle=False)
  
  # Call predict() on the linear_regressor to make predictions.
  predictions = linear_regressor.predict(input_fn = prediction_input_fn
    )
  
  # Format predictions as a NumPy array, so we can calculate error metrics.
  predictions = np.array([item['predictions'][0] for item in predictions])
  </code></pre>
  
  <p>Full traceback:</p>
  
  <pre><code>WARNING:tensorflow:Using temporary folder as model directory: C:\Users\Username\
  AppData\Local\Temp\tmpowu7j37s
  C:\Users\Username\AppData\Local\Temp\tmpowu7j37s
  Traceback (most recent call last):
    File "fstf.py", line 104, in &lt;module&gt;
      predictions = np.array([item['predictions'][0] for item in predictions])
    File "fstf.py", line 104, in &lt;listcomp&gt;
      predictions = np.array([item['predictions'][0] for item in predictions])
    File "C:\Users\Username\AppData\Local\conda\conda\envs\tensorflow\lib\site-pac
  kages\tensorflow\python\estimator\estimator.py", line 471, in predict
      self._model_dir))
  ValueError: Could not find trained model in model_dir: C:\Users\Username\AppData
  \Local\Temp\tmpowu7j37s.
  </code></pre>