title: Confused between whether or not to change the class_mode from binary to categorical in Imagedatagenerator
body: <p>When i shifted from 2 classes to 4 classes in a CNN model. I got errors. A lot of people helped me solve them, like I needed to change loss to <code>sparse_categorical_crossentropy</code> and last layer activation function.</p>
  
  <pre><code>model.compile(loss='sparse_categorical_crossentropy',
                optimizer='adam',
                metrics=['accuracy'])
  
  history = model.fit_generator(
      train_generator,
      steps_per_epoch=nb_train_samples//batch_size,
      epochs=epochs,
      validation_data = validation_generator, 
      validation_steps = validation_generator.samples // batch_size,
  )
  </code></pre>
  
  <p>I am confused as I had to change the loss function from <code>binary_crossentropy</code> to <code>categorical_crossenpropy</code>. I want to know whether I should change the class_mode from binary to categorical for 4 classes or should I leave it as binary.</p>
  
  <pre><code>train_datagen=ImageDataGenerator(
      rescale=1./255,
      shear_range=0.2,
      zoom_range=0.2,
      horizontal_flip = True,
      #vertical_flip = True,
      validation_split=0.2,
      brightness_range=[0.5, 1.5]
  
  )
  
  #test_datagen = ImageDataGenerator(
   #   rescale=1./255,
   #   
  #)
  
  train_generator = train_datagen.flow_from_directory(
      train_data_dir,
      target_size=(img_width,img_height),
      batch_size=batch_size,
      shuffle=True,
      class_mode='binary',
      subset='training'
  )
  
  validation_generator = train_datagen.flow_from_directory(
      train_data_dir, # same directory as training data
      target_size=(img_height, img_width),
      batch_size=batch_size,
      class_mode='binary',
      subset='validation'
      #validation_data_dir,
      #target_size=(img_width,img_height),
      #batch_size=batch_size,
      #class_mode='binary'
  )
  </code></pre>