title: Get error when max_length not equal to n_tags in multilabel classification
body: <p>I'm trying to make multilabel classification of chat messages by their tags. I've converted 21 tags to 21 binary columns and applied tokenizer and padding to make length of all chat messages = 21. This messages also were converted to 21 columns (every word in a different column). So n_tags = 21 and max_length = 21. It works well.</p>
  <pre><code>def ElmoEmbedding(x):
      return elmo_model(inputs={&quot;tokens&quot;: tf.squeeze(tf.cast(x, tf.string)),
      &quot;sequence_len&quot;: tf.constant(batch_size*[max_len])}, signature=&quot;tokens&quot;,as_dict=True) 
      [&quot;elmo&quot;]
  sess = tf.Session()
  K.set_session(sess)
  
  elmo_model = hub.Module(&quot;http://files.deeppavlov.ai/deeppavlov_data/elmo_ru-news_wmt11-16_1.5M_steps.tar.gz&quot;, trainable=True)
  
  sess.run(tf.global_variables_initializer())
  sess.run(tf.tables_initializer())
  
  input_text = Input(shape=(max_len,), dtype='string')
  embedding = Lambda(ElmoEmbedding, output_shape=(max_len, 1024))(input_text)
  
  x = Bidirectional(LSTM(units=512, return_sequences=True, recurrent_dropout=0.2, dropout=0.2))(embedding)
  x_rnn = Bidirectional(LSTM(units=512, return_sequences=True, recurrent_dropout=0.2, dropout=0.2))(x)
  x = add([x, x_rnn])  
  out = TimeDistributed(Dense(n_tags, activation=&quot;softmax&quot;))(x)
  
  model = Model(input_text, out)
  model.compile(optimizer=&quot;adam&quot;, loss=&quot;sparse_categorical_crossentropy&quot;, metrics=[tf.keras.metrics.SparseCategoricalAccuracy('accuracy')])
  
  for fold_num in range(N_SPLITS): 
  
      test = df[df.fold_num == fold_num].drop('fold_num', axis=1).reset_index(drop=True)
      train = df[df.fold_num != fold_num].drop('fold_num', axis=1).reset_index(drop=True)
  
      X_tr = train.iloc[:,21:].apply(lambda x: x.astype('str')).to_numpy()
      X_te = test.iloc[:,21:].apply(lambda x: x.astype('str')).to_numpy()
  
      y_tr = train.iloc[:,0:21].apply(lambda x: x.astype('float32')).to_numpy()
      y_te = test.iloc[:,0:21].apply(lambda x: x.astype('float32')).to_numpy()
  
      X_tr, X_val = X_tr[train.shape[0]%batch_size:], X_te[test.shape[0]%batch_size:]
      y_tr, y_val = y_tr[train.shape[0]%batch_size:], y_te[test.shape[0]%batch_size:]
  
      y_tr = y_tr.reshape(y_tr.shape[0], y_tr.shape[1], 1)
      y_val = y_val.reshape(y_val.shape[0], y_val.shape[1], 1)
  
      history = model.fit(np.array(X_tr), y_tr, validation_data=(np.array(X_val), y_val), 
                      batch_size=batch_size, epochs=1, verbose=1) 
  </code></pre>
  <p>But when I try to make max_length greater it gives me the following error:</p>
  <pre><code>InvalidArgumentError: 2 root error(s) found.
    (0) INVALID_ARGUMENT: required broadcastable shapes
       [[{{node metrics_2/accuracy/Equal}}]]
       [[metrics_2/accuracy/Identity/_597]]
    (1) INVALID_ARGUMENT: required broadcastable shapes
       [[{{node metrics_2/accuracy/Equal}}]]
  0 successful operations.
  0 derived errors ignored.
  </code></pre>
  <p>I thought that the problem is in SparseCategoricalAccuracy. I tried to change it to BinaryAccuracy but it gives arrors. I'm new to keras, could you explain to me how to improve the code?</p>