title: How to model Convolutional recurrent network ( CRNN ) in Keras
body: <p>I was trying to port <a href="https://github.com/meijieru/crnn.pytorch/blob/master/models/crnn.py" rel="noreferrer">CRNN</a> model to Keras.</p>
  
  <p>But, I got stuck while connecting output of Conv2D layer to LSTM layer.</p>
  
  <p>Output from CNN layer will have a shape of <strong>( batch_size, 512, 1, width_dash)</strong> where first one depends on batch_size, and last one depends on input width of input ( this model can accept variable width input )</p>
  
  <p>For eg: an input with shape <strong>[2, 1, 32, 829]</strong> was resulting output with shape of <strong>(2, 512, 1, 208)</strong></p>
  
  <p>Now, as per <a href="https://github.com/meijieru/crnn.pytorch/blob/ab61ff13c204a03d08b2836f39688c851f50fb12/models/crnn.py#L73" rel="noreferrer">Pytorch model</a>, we have to do <strong>squeeze(2)</strong>  followed by <strong>permute(2, 0, 1)</strong> 
  it will result a tensor with shape [208, 2, 512 ]</p>
  
  <p>I was trying to implement this is Keras, but I was not able to do that because, in Keras we can not alter batch_size dimension in a <strong>keras.models.Sequential</strong> model</p>
  
  <p>Can someone please guide me how to port above part of this model to Keras?</p>
  
  <p><a href="https://hastebin.com/uceyovenin.md" rel="noreferrer">Current state of ported CNN layer</a></p>