title: ValueError: Layer weight shape (32, 128) not compatible with provided weight shape (32, 64)
body: <p>I'm training an autoencoder and after tuning the autoencoder, I'm taking the encoder part, add a fully connected layer for a regression problem. After training the autoencoder, when I'm trying to combine the encoder and fully connected layer, it shows the following error</p>
  
  <p><code>ValueError: Dimension 1 in both shapes must be equal, but are 128 and 64. Shapes are [32,128] and [32,64]. for 'Assign_36' (op: 'Assign') with input shapes: [32,128], [32,64].</code></p>
  
  <p>I understand somewhere I have a mismatched dimension but I can't identify. Sorry, I'm new to this. Here are the relevant codes.</p>
  
  <pre><code>def encoder(input_data):
      encoder1 = Dense(128, activation = 'relu')(input_data)
      encoder1 = BatchNormalization()(encoder1)
      encoder1 = Dense(128, activation = 'relu')(encoder1)
      encoder1 = BatchNormalization()(encoder1)
  
      encoder2 = Dense(64, activation = 'relu')(encoder1)
      encoder2 = BatchNormalization()(encoder2)
      encoder2 = Dense(64, activation = 'relu')(encoder2)
      encoder2 = BatchNormalization()(encoder2)
  
      encoder3 = Dense(32, activation = 'relu')(encoder2)
      encoder3 = BatchNormalization()(encoder3)
      encoder3 = Dense(32, activation = 'relu')(encoder3)
      encoder3 = BatchNormalization()(encoder3)
  
      return encoder3
  
  def decoder(encoder, input_data):
      decoder3 = Dense(64, activation = 'relu')(encoder)
      decoder3 = BatchNormalization()(decoder3)
      decoder3 = Dense(64, activation = 'relu')(decoder3)
      decoder3 = BatchNormalization()(decoder3)
  
      decoder2 = Dense(128, activation = 'relu')(decoder3)
      decoder2 = BatchNormalization()(decoder2)
      decoder2 = Dense(128, activation = 'relu')(decoder2)
      decoder2 = BatchNormalization()(decoder2)
  
      decoder1 = Dense(788, activation = 'sigmoid')(decoder2)
  
      return decoder1
  
  def fc(enco):
      den = Dense(128, activation = 'relu')(enco)
      out = Dense(1, activation = 'tanh')(den)
  
      return out
  
  input_data = Input(shape=(788, ))
  autoencoder = Model(input_data, decoder(encoder(input_data), input_data))
  autoencoder.compile(optimizer = 'adadelta', loss ='mse')
  autoencoder.fit(train_x, train_x,
                  epochs = 5,
                  batch_size = 32,
                  shuffle = True,
                  validation_data = (test_x, test_x))
  
  # building combined model
  encode = encoder(input_data)
  full_model = Model(input_data, fc(encode))
  full_model.set_weights(autoencoder.get_weights())    # ValueError
  </code></pre>