title: Shapes are incompatible with Keras Functional Model and VGG16 model
body: <p>I'm a little lost right now trying to merge my own model layers using Keras Functional API and layers from a VGG16 model into one new model. I need to add new layers after block3_pool with my custom ones. There is 8 classes that will be used (Fashion Mnist). All images are scaled up from 28x28 to 32x32. This is how far I've come:</p>
  <pre><code># VGG16 Model
  vgg_model = VGG16(include_top=False, weights='imagenet', input_shape=(32, 32, 3), classes=8)
  vgg_model.save_weights('vgg.model')
  # vgg_model.summary()
  
  for layer in model.layers:
     layer.trainable = False
  
  inputs = Input(shape=(4, 4,))
  x = tf.keras.layers.Dense(64, activation=tf.nn.relu)(inputs)
  outputs = tf.keras.layers.Dense(8, activation=tf.nn.softmax)(x)
  
  new_model = tf.keras.Model(inputs=inputs, outputs=outputs, name='new_model')
  new_model.load_weights('vgg.model')
  
  block3_pool = vgg_model.get_layer('block3_pool').output
  
  # Now combine the two models
  full_output = new_model(block3_pool)
  full_model = Model(inputs=vgg_model.input, outputs=full_output)
  full_model.summary()
  </code></pre>
  <p>When trying to run this code I get the following error in Google Colab:</p>
  <pre><code>/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/tensor_shape.py in assert_is_compatible_with(self, other)
     1132     &quot;&quot;&quot;
     1133     if not self.is_compatible_with(other):
  -&gt; 1134       raise ValueError(&quot;Shapes %s and %s are incompatible&quot; % (self, other))
     1135 
     1136   def most_specific_compatible_shape(self, other):
  
  ValueError: Shapes (4, 64) and (3, 3, 3, 64) are incompatible
  </code></pre>
  <p>I do not seem to understand completely why that is and what I have to do to make it work.</p>