title: Value error while training model in Keras
body: <p>I tried to train a model to predict ocr in keras. This is the code snippet where the model tries to fit the data:</p>
  <pre><code>nb_epoch = 8
  
  samples_per_epoch = 3268
  nb_val_samples = 842
  
  
  #save every model using Keras checkpoint
  from keras.callbacks import ModelCheckpoint
  filepath=&quot;checkpoint2/check-{epoch:02d}-{val_loss:.4f}.hdf5&quot;
  checkpoint = ModelCheckpoint(filepath= filepath, verbose=1, save_best_only=False)
  callbacks_list = [checkpoint]
  
  #Model fit generator
  history_object = model.fit(train_generator, 
                             steps_per_epoch= samples_per_epoch,
                             validation_data=validation_generator,
                             validation_steps=nb_val_samples, 
                             epochs=nb_epoch, 
                             verbose=1, 
                             callbacks=callbacks_list)
  </code></pre>
  <p>I ran the cell and the program got stuck at the first epoch and threw the following error:</p>
  <pre><code>ValueError                                Traceback (most recent call last)
  &lt;ipython-input-15-62090a608d4c&gt; in &lt;module&gt;
       20                                      epochs=nb_epoch,
       21                                      verbose=1,
  ---&gt; 22                                      callbacks=callbacks_list)
  .
  .
  .
   ValueError: Layer sequential_1 expects 1 input(s), but it received 2 input tensors. Inputs received: [&lt;tf.Tensor 'IteratorGetNext:0' shape=(None, None, None, None) dtype=float32&gt;, &lt;tf.Tensor 'IteratorGetNext:1' shape=(None, None) dtype=float32&gt;]
  </code></pre>
  <p>I have just started to build models using keras. I took this code from a github repo as a learning material. Kindly help me to solve this issue.
  thank you so much.</p>
  <p>edit: Here is the train_generator code:</p>
  <pre><code>batch_size = 16
  num_classes = 50
  
  # Start with train generator shared in the class and add image augmentations
  def generate_data(samples, target_files,  batch_size=batch_size, factor = 0.1 ):
      num_samples = len(samples)
      from sklearn.utils import shuffle
      while 1: # Loop forever so the generator never terminates
          for offset in range(0, num_samples, batch_size):
              batch_samples = samples[offset:offset+batch_size]
              batch_targets = target_files[offset:offset+batch_size]
  
              images = []
              targets = []
              for i in range(len(batch_samples)):
                  batch_sample = batch_samples[i]
                  batch_target = batch_targets[i]
                  im = Image.open(batch_sample)
                  cur_width = im.size[0]
                  cur_height = im.size[1]
  
                  # print(cur_width, cur_height)
                  height_fac = 113 / cur_height
  
                  new_width = int(cur_width * height_fac)
                  size = new_width, 113
  
                  imresize = im.resize((size), Image.ANTIALIAS)  # Resize so height = 113 while keeping aspect ratio
                  now_width = imresize.size[0]
                  now_height = imresize.size[1]
                  # Generate crops of size 113x113 from this resized image and keep random 10% of crops
  
                  avail_x_points = list(range(0, now_width - 113 ))# total x start points are from 0 to width -113
  
                  # Pick random x%
                  pick_num = int(len(avail_x_points)*factor)
  
                  # Now pick
                  random_startx = sample(avail_x_points,  pick_num)
  
                  for start in random_startx:
                      imcrop = imresize.crop((start, 0, start+113, 113))
                      images.append(np.asarray(imcrop))
                      targets.append(batch_target)
                      
                      
           # trim image to only see section with road
              X_train = np.array(images)
              y_train = np.array(targets)
  
              #reshape X_train for feeding in later
              X_train = X_train.reshape(X_train.shape[0], 113, 113, 1)
              #convert to float and normalize
              X_train = X_train.astype('float32')
              X_train /= 255
  
              #One hot encode y
              y_train = to_categorical(y_train, num_classes)
  
              yield shuffle(X_train, y_train) 
  
  
  train_generator = generate_data(train_files, train_targets, batch_size=batch_size, factor = 0.3)
  validation_generator = generate_data(validation_files, validation_targets, batch_size=batch_size, factor = 0.3)
  test_generator = generate_data(test_files, test_targets, batch_size=batch_size, factor = 0.1)
  </code></pre>