title: ValueError: Input 0 is incompatible with layer batch_normalization_1: expected ndim=3, found ndim=2
body: <p>I am trying to use the implementetion of DeepTriage which is a deep learning approach for bug triaging. <a href="http://bugtriage.mybluemix.net/" rel="nofollow noreferrer">This website</a> includes dataset, source code and paper. I know that is a very specific area, but I'll try to make it simple. </p>
  
  <p>In <a href="http://bugtriage.mybluemix.net/#code" rel="nofollow noreferrer">the source code</a> they define their approach "DBRNN-A: Deep Bidirectional Recurrent Neural Network with Attention mechanism and with Long Short-Term Memory units (LSTM)" with this code part:</p>
  
  <pre><code>input = Input(shape=(max_sentence_len,), dtype='int32')
  sequence_embed = Embedding(vocab_size, embed_size_word2vec, input_length=max_sentence_len)(input)
  
  forwards_1 = LSTM(1024, return_sequences=True, dropout_U=0.2)(sequence_embed)
  attention_1 = SoftAttentionConcat()(forwards_1)
  after_dp_forward_5 = BatchNormalization()(attention_1)
  
  backwards_1 = LSTM(1024, return_sequences=True, dropout_U=0.2, go_backwards=True)(sequence_embed)
  attention_2 = SoftAttentionConcat()(backwards_1)
  after_dp_backward_5 = BatchNormalization()(attention_2)
  
  merged = merge([after_dp_forward_5, after_dp_backward_5], mode='concat', concat_axis=-1)
  after_merge = Dense(1000, activation='relu')(merged)
  after_dp = Dropout(0.4)(after_merge)
  output = Dense(len(train_label), activation='softmax')(after_dp)                
  model = Model(input=input, output=output)
  model.compile(loss='categorical_crossentropy', optimizer=Adam(lr=1e-4), metrics=['accuracy']) 
  </code></pre>
  
  <p><code>SoftAttentionConcat</code> implementation is from <a href="https://gist.github.com/braingineer/27c6f26755794f6544d83dec2dd27bbb" rel="nofollow noreferrer">here</a>. Rest of the functions are from <code>keras</code>. Also, in <a href="http://bugtriage.mybluemix.net/#paper" rel="nofollow noreferrer">the paper</a> they share the structure as:</p>
  
  <p><a href="https://i.stack.imgur.com/ABRhr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ABRhr.png" alt="DBRNN-A"></a></p>
  
  <p>In the first batch normalization line, it throws this error:</p>
  
  <pre><code>ValueError: Input 0 is incompatible with layer batch_normalization_1: expected ndim=3, found ndim=2
  </code></pre>
  
  <p>When I use <code>max_sentence_len=50</code> and <code>max_sentence_len=200</code> I look at the dimension until the error point, I see these shapes:</p>
  
  <pre><code>Input               -&gt; (None, 50)
  Embedding           -&gt; (None, 50, 200)
  LSTM                -&gt; (None, None, 1024)
  SoftAttentionConcat -&gt; (None, 2048) 
  </code></pre>
  
  <p>So, is there anybody seeing the problem here?</p>