title: tensorflow MNIST fully_connected_feed.py fails: range() takes at least 2 arguments (1 given)
body: <p>I'm having trouble running the example in one of the <a href="http://tensorflow.org/tutorials/mnist/tf/index.md" rel="nofollow noreferrer">tensor flow tutorials</a>. The tutorial says to run I just need to type <code>python fully_connected_feed.py</code>. When I do this it gets through fetching the input data, but then fails, like so:</p>
  
  <pre class="lang-py prettyprint-override"><code>Extracting data/train-images-idx3-ubyte.gz
  Extracting data/train-labels-idx1-ubyte.gz
  Extracting data/t10k-images-idx3-ubyte.gz
  Extracting data/t10k-labels-idx1-ubyte.gz
  Traceback (most recent call last):
    File "fully_connected_feed.py", line 225, in &lt;module&gt;
      tf.app.run()
    File "/Users/me/anaconda/lib/python2.7/site-packages/tensorflow/python/platform/default/_app.py", line 11, in run
      sys.exit(main(sys.argv))
    File "fully_connected_feed.py", line 221, in main
      run_training()
    File "fully_connected_feed.py", line 141, in run_training
      loss = mnist.loss(logits, labels_placeholder)
    File "/Users/me/tftmp/mnist.py", line 96, in loss
      indices = tf.expand_dims(tf.range(batch_size), 1)
  TypeError: range() takes at least 2 arguments (1 given)
  </code></pre>
  
  <p>I <em>think</em> this error is caused because there is some problem with session setup and/or tensor evaluation. This is the function in mnist.py causing the problem:</p>
  
  <pre class="lang-py prettyprint-override"><code>def loss(logits, labels):
    """Calculates the loss from the logits and the labels.
  
    Args:
      logits: Logits tensor, float - [batch_size, NUM_CLASSES].
      labels: Labels tensor, int32 - [batch_size].
  
    Returns:
      loss: Loss tensor of type float.
    """
    # Convert from sparse integer labels in the range [0, NUM_CLASSSES)
    # to 1-hot dense float vectors (that is we will have batch_size vectors,
    # each with NUM_CLASSES values, all of which are 0.0 except there will
    # be a 1.0 in the entry corresponding to the label).
    batch_size = tf.size(labels)
    labels = tf.expand_dims(labels, 1)
    indices = tf.expand_dims(tf.range(batch_size), 1)
    concated = tf.concat(1, [indices, labels])
    onehot_labels = tf.sparse_to_dense(
        concated, tf.pack([batch_size, NUM_CLASSES]), 1.0, 0.0)
    cross_entropy = tf.nn.softmax_cross_entropy_with_logits(logits, onehot_labels,
                                                            name='xentropy')
    loss = tf.reduce_mean(cross_entropy, name='xentropy_mean')
    return loss
  </code></pre>
  
  <p>If I put all the code in the <code>loss</code> function inside a <code>with tf.Session():</code> block, it gets past this error. However, I get other errors later about uninitialised variables, so I'm guessing something major is going wrong with session setup or initialisation, or something. Being new to tensor flow I'm a little at a loss. Any ideas?  </p>
  
  <p>[NB: I havent edited the code at all, just downloaded from the tensorflow tutorials and tried to run as instructed, with <code>python fully_connected_feed.py</code>]   </p>