title: Incompatible shapes: [128,28] vs. [128,29] in validation
body: <p>I am training a seq2seq model.i have a training set with (x,1212)  shape and validation set with (x,29) shape. when i try to train my below model. it is throwing me an error in validation.</p>
  
  <p>Error:</p>
  
  <blockquote>
    <p>File "C:\Users\X\eclipse-workspace\TextSummerization\main\process.py",
    line 184, in 
        history=model.fit([X_train,Y_train], Y_train.reshape(Y_train.shape[0],Y_train.shape[1], 1)[:,1:]
    ,epochs=2,batch_size=128, validation_data=([X_test,Y_test], 
    Y_test.reshape(Y_test.shape[0],Y_test.shape[1], 1)[:,1:]))   File
    "C:\Users\X\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\keras\engine\training.py",
    line 1363, in fit
        validation_steps=validation_steps)   File "C:\Users\X\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\keras\engine\training_arrays.py",
    line 264, in fit_loop
        outs = f(ins_batch)   File "C:\Users\X\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\keras\backend.py",
    line 2914, in <strong>call</strong>
        fetched = self._callable_fn(*array_vals)   File "C:\Users\X\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\client\session.py",
    line 1382, in <strong>call</strong>
        run_metadata_ptr)   File "C:\Users\X\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\framework\errors_impl.py",
    line 519, in <strong>exit</strong>
        c_api.TF_GetCode(self.status.status)) tensorflow.python.framework.errors_impl.InvalidArgumentError:
    Incompatible shapes: [128,28] vs. [128,29]     [[Node: metrics/acc/Equal
    = Equal[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"](metrics/acc/Max,
    metrics/acc/Cast)]]</p>
  </blockquote>
  
  <p>when i change optimizer to </p>
  
  <blockquote>
    <p>adam</p>
  </blockquote>
  
  <p>and loss to </p>
  
  <blockquote>
    <p>categorical</p>
  </blockquote>
  
  <p>it is giving me another error: `</p>
  
  <blockquote>
    <p>Error when checking target: expected time_distributed to have shape
    (None, 14847) but got array with shape (28, 1)</p>
  </blockquote>
  
  <p>`</p>
  
  <pre><code># Encoder 
  encoder_inputs = Input(shape=(X_train.shape[1],)) 
  enc_emb = Embedding(x_voc_size, latent_dim,trainable=True)(encoder_inputs) 
  
  #LSTM 1 
  encoder_lstm1 = LSTM(latent_dim,return_sequences=True,return_state=True) 
  encoder_output1, state_h1, state_c1 = encoder_lstm1(enc_emb) 
  
  #LSTM 2 
  encoder_lstm2 = LSTM(latent_dim,return_sequences=True,return_state=True) 
  encoder_output2, state_h2, state_c2 = encoder_lstm2(encoder_output1) 
  
  #LSTM 3 
  encoder_lstm3=LSTM(latent_dim, return_state=True, return_sequences=True) 
  encoder_outputs, state_h, state_c= encoder_lstm3(encoder_output2) 
  
  # Set up the decoder. 
  decoder_inputs = Input(shape=(None,)) 
  dec_emb_layer = Embedding(y_voc_size, latent_dim,trainable=True) 
  dec_emb = dec_emb_layer(decoder_inputs) 
  
  #LSTM using encoder_states as initial state
  decoder_lstm = LSTM(latent_dim, return_sequences=True, return_state=True) 
  decoder_outputs,decoder_fwd_state, decoder_back_state = decoder_lstm(dec_emb,initial_state=[state_h, state_c]) 
  
  #Attention Layer
  attn_layer = AttentionLayer(name='attention_layer') 
  attn_out, attn_states = attn_layer([encoder_outputs, decoder_outputs]) 
  
  # Concat attention output and decoder LSTM output 
  decoder_concat_input = Concatenate(axis=-1, name='concat_layer')([decoder_outputs, attn_out])
  
  #Dense layer
  decoder_dense = TimeDistributed(Dense(y_voc_size, activation='softmax')) 
  decoder_outputs = decoder_dense(decoder_concat_input) 
  
  # Define the model
  model = Model([encoder_inputs, decoder_inputs], decoder_outputs) 
  model.summary()
  
  model.compile(optimizer='rmsprop', loss='sparse_categorical_crossentropy',metrics=['accuracy'])
  
  #monitoring loss here, if loss increases we will stop training.
  #es = EarlyStopping(monitor='val_loss', mode='min', verbose=1)
  
  history=model.fit([X_train,Y_train], Y_train.reshape(Y_train.shape[0],Y_train.shape[1], 1)[:,1:] ,epochs=2,batch_size=128, validation_data=([X_test,Y_test],  Y_test.reshape(Y_test.shape[0],Y_test.shape[1], 1)[:,1:]))
  </code></pre>