title: Keras. Is it possible to use the batch output of a layer as input of the next layer?
body: <p>I am trying to train a Keras implementation of VGGish. 
  <a href="https://github.com/tensorflow/models/tree/master/research/audioset" rel="nofollow noreferrer">https://github.com/tensorflow/models/tree/master/research/audioset</a>
  VGGish purpose is to classify audio data.</p>
  
  <p>VGGish takes as input a batch of mel spectrograms (basically, these are pictures), each spectrogram being the representation of 1 second and returns a batch of embeddings of shape <code>(batch size, 128)</code>. So to process a 10 seconds long audio file, you first convert it as a batch of 10 mel spectogram, and you get an output of shape <code>(10, 128)</code>.</p>
  
  <p>Now, I would like to add a classifier on top of VGGish, that means adding layers. As the shape <code>(10, 128)</code> is a time series I would like to convolve on the first dimension or use a LSTM, whatever is suited.</p>
  
  <p>The problem is that the shape of the embbedding is determined by <code>(batch size, units=128)</code>.</p>
  
  <p>In short, you input a batch of <code>n</code> seconds. What I would like to do, is being able to input a batch of <code>n</code> files of 10 seconds, and work at the file level, not the second level.</p>
  
  <p>It gives me headache, really.</p>
  
  <p>The beginning of the VGGish is like this :</p>
  
  <pre><code>input_shape = (vggish_params.NUM_FRAMES,vggish_params.NUM_BANDS)
  
  img_input = Input( shape=input_shape)
  reshaped = Reshape((vggish_params.NUM_FRAMES,vggish_params.NUM_BANDS,1))(img_input)
  # Block 1
  x = Conv2D(64, (3, 3), activation='relu', padding='same', name='conv1')(reshaped)
  x = MaxPooling2D((2, 2), strides=(2, 2), name='pool1')(x)
  </code></pre>
  
  <p>The Reshape layer serves to be able to Conv 2D. The output layer for embedding looks like this :</p>
  
  <pre><code>x = Dense(128, activation='relu', name='fc2')(x)
  </code></pre>
  
  <p>What I would like to do overall is to add one dimension. What I mean by this is inputting batches of <code>n</code> seconds audio clips, instead of batches of n 1-second clips.</p>
  
  <p>I really have no clue on how to do that, and I don't know if it's even possible. I come here for help, because I'm really really puzzled.</p>
  
  <p>Any idea ?
  Cheers.</p>