title: Keras-SegNet use ImageDataGenerator and fit or fit_generator
body: <p>Problems about import data set is going to drive me crazy.</p>
  
  <p>This is part of my segnet code. </p>
  
  <p>I'll focus on the questions about image&amp;mask data import.</p>
  
  <pre><code>print("CNN Model created.")
  
  ###training data
  data_gen_args = dict()
  image_datagen = ImageDataGenerator(**data_gen_args)
  mask_datagen = ImageDataGenerator(**data_gen_args)
  seed1 = 1
  image_datagen.fit(images, augment=True, seed=seed1)
  mask_datagen.fit(masks, augment=True, seed=seed1)
  
  train_image_generator = image_datagen.flow_from_directory(TRAIN_im,target_size=(500, 500),batch_size=BATCH_SIZE, class_mode = None)
  train_mask_generator = mask_datagen.flow_from_directory(TRAIN_mask,target_size=(500, 500),batch_size=BATCH_SIZE, class_mode = None)
  
  train_generator = zip(train_image_generator,train_mask_generator)
  
  ###validation data
  valid_gen_args = dict()
  val_image_datagen = ImageDataGenerator(**valid_gen_args)
  val_mask_datagen = ImageDataGenerator(**valid_gen_args)
  seed2 = 5
  val_image_datagen.fit(val_images, augment=True, seed=seed2)
  val_mask_datagen.fit(val_masks, augment=True, seed=seed2)
  
  val_image_generator = val_image_datagen.flow_from_directory(VAL_im,target_size=(500, 500),batch_size=BATCH_SIZE, class_mode = None)
  val_mask_generator = val_mask_datagen.flow_from_directory(VAL_mask,target_size=(500, 500),batch_size=BATCH_SIZE, class_mode = None)
  
  val_generator = zip(val_image_generator,val_mask_generator)
  
  ###
  model.fit_generator(
  train_generator,steps_per_epoch=nb_train_samples//BATCH_SIZE,epochs=EPOCHS,validation_data=val_generator,validation_steps=nb_validation_samples//BATCH_SIZE)
  </code></pre>
  
  <blockquote>
    <p>My question is:</p>
  </blockquote>
  
  <ol>
  <li><p>I change the input size to 500*500, so I adjusted the pooling and upsample layers size. Is this achievable?
  Further more, can I make the classic net(Like AlexNet, VGG, Segnet...) accept arbitrary input image size by adjusting their pooling and upsample layers size and filter numbers?</p></li>
  <li><p>I'd like to know what is the data type of variables "images" and "masks" in:</p>
  
  <pre><code>image_datagen.fit(images, augment=True, seed=seed1)
  mask_datagen.fit(masks, augment=True, seed=seed1)
  </code></pre>
  
  <p>This part is from Keras official tutorial.(Ans:Now I know they both are numpy arrays.)</p></li>
  <li><p>According to the question above. How can I derive them?</p>
  
  <p>Should I write a function like mnist.load_data() below?</p>
  
  <p>I need some examples.</p>
  
  <pre><code>    (x_train_image, y_train_label), (x_test_image, y_test_label) = mnist.load_data()
  </code></pre></li>
  <li><p>I use the function </p>
  
  <pre><code>flow_from_directory
  </code></pre>
  
  <p>Does it mean there is no need to define a function like
  "mnist.load_data()" by myself, and I can use it to get the (batch,shuffle) data directly from my directory structure?</p></li>
  </ol>
  
  <p>This is my directory structure:</p>
  
  <pre><code>Dataset -training----------images----"many images"
             |         |
             |         |-----mask-----"ground truth images(mask)" 
             |
             |
         validation----------val_images----"many images"
             |        |
             |        |------val_mask------"ground truth images(mask)" 
             |
             |
          testing---------------test images (no ground truth)
  </code></pre>
  
  <p>Thanks a lot!</p>