title: How to get labels ids in Keras when training on multiple classes?
body: <p>I'm using <a href="http://keras.io/preprocessing/image/" rel="noreferrer"><code>flow_from_directory</code></a> to get the training set from a folder with the following structure:</p>
  
  <pre><code>train
    class1
    class2
    class3
    ...
  </code></pre>
  
  <p>The generator is called as it follows:</p>
  
  <pre><code>train_generator = train_datagen.flow_from_directory( 
          train_data_dir,                              
          target_size=(img_height, img_width),         
          batch_size=32,                               
          class_mode='categorical')  
  </code></pre>
  
  <p>I am not setting the argument <code>classes</code>, but I was expecting to get the labels in alphabetical order.</p>
  
  <blockquote>
    <p><strong>classes</strong>: optional list of class subdirectories (e.g. <code>['dogs', 'cats']</code>). Default: None. If not provided, the list of classes will be automatically inferred (and the order of the classes, which will map to the label indices, will be alphanumeric).</p>
  </blockquote>
  
  <p>However, when I classify the training images (for checking which labels are being returned), I'm don't get any specific ordering. The training goes well (accuracy of ~85%), and there is a consistency with the output labels when classifying images from the same class.</p>
  
  <p>How can I infer the labels numbers generated by <code>flow_from_directory</code> and map them to the classes?</p>