title: ValueError when using ModelCheckpoint in Keras
body: <p>I'm creating an Ensemble of Vgg19, DenseNet, and EfficientNetB1.</p>
  <p>The code is as follows:</p>
  <pre><code>IMAGE_SIZE = (224,224,3)
  
  import tensorflow as tf
  vgg19 = tf.keras.applications.vgg19.VGG19(
      input_shape=IMAGE_SIZE, weights='imagenet', include_top=False)
  for layer in vgg19.layers:
      layer._name = layer._name + str('_19')
      layer.trainable = False
  
  effnetb1 =tf.keras.applications.efficientnet.EfficientNetB1(
      include_top=False, weights='imagenet', input_shape=IMAGE_SIZE)
  for layer in effnetb1.layers:
      layer._name = layer._name + str('_B1')
      layer.trainable=False
  
  densenet=tf.keras.applications.densenet.DenseNet121(
      include_top=False, weights=&quot;imagenet&quot;, input_shape=IMAGE_SIZE)
  for layer in densenet.layers:
      layer._name = layer._name + str('_Dense')
      layer.trainable=False
  
  
  from keras.layers import Input, Flatten, Concatenate, Dense, Average, Dropout
  inp = Input(IMAGE_SIZE)
      
  vgg19_x = Flatten()(vgg19(inp))
  vgg19_x = Dense(256, activation='relu')(vgg19_x)
  
  effnet_x = Flatten()(effnetb1(inp))
  effnet_x = Dense(256, activation='relu')(effnet_x)
  
  densenet_x = Flatten()(densenet(inp))
  densenet_x = Dense(256, activation='relu')(densenet_x)
  
  from keras.models import Model
  
  x = Concatenate()([vgg19_x, effnet_x, densenet_x])
  x = Dense(128, activation='relu')(x)
  x = Dropout(0.30)(x)
  x = Dense(64, activation='relu')(x)
  out = Dense(2, activation='softmax')(x)
  
  model = Model(inputs = inp, outputs = out)
  model.compile(
    loss='categorical_crossentropy',
    optimizer=tf.keras.optimizers.Adam(
      learning_rate=0.0005,
      name=&quot;Adam&quot;),
    metrics=['accuracy']
  )
  model.summary()
  
  from tensorflow.keras.callbacks import EarlyStopping, ModelCheckpoint
  
  checkpointer = ModelCheckpoint(filepath=&quot;/content/drive/MyDrive/ensemble/ensemble-weights.hdf5&quot;, verbose=1, save_best_only=True)
  
  r = model.fit(
    training_set,
    validation_data=test_set,
    epochs=30,
    steps_per_epoch=len(training_set),
    validation_steps=len(test_set),
    callbacks = [checkpointer]
  )
  </code></pre>
  <p>The code runs fine and the training is successfully taking place when I'm not using the callback. But when I use a <code>ModelCheckpoint</code>, I get the following error after 1st epoch:</p>
  <pre><code>ValueError: The target structure is of type `&lt;class 'keras.engine.keras_tensor.KerasTensor'&gt;`
    KerasTensor(type_spec=TensorSpec(shape=(None, 224, 224, 3), dtype=tf.float32, name='input_5'), name=...
  However, the input structure is a sequence (&lt;class 'list'&gt;) of length 0.
    []
  nest cannot guarantee that it is safe to map one to the other.
  </code></pre>
  <p>Can anyone tell me what's wrong here? Also, is it because I'm concatenating three models?</p>
  <p>Your help will be appreciated. Thank you!</p>