title: How to make Keras have two different initialisers in a dense layer?
body: <p>I have two separately designed CNNs for two different features(image and text) of the same data, and the output has two classes</p>
  
  <p>In the very last layer:</p>
  
  <p>for image (resnet), I would like to use "he_normal" as the initializer</p>
  
  <pre><code>flatten1 = Flatten()(image_maxpool)
  dense = Dense(output_dim=2, kernel_initializer="he_normal")(flatten1)
  </code></pre>
  
  <p>but for the text CNNs, i would like to use the default "glorot_normal"</p>
  
  <pre><code>flatten2 = Flatten()(text_maxpool)
  output = Dense(output_dim=2, kernel_initializer="glorot_normal")(flatten2)
  </code></pre>
  
  <p>the flatten1 and flatten2 have sizes:</p>
  
  <p>flatten_1 (Flatten)  (None, 512)</p>
  
  <p>flatten_2 (Flatten)  (None, 192)</p>
  
  <p>is there anyway i can concate these two flatten layers and have a long dense layer with a size 192+512 = 704, where the first 192 and second 512 has two seperate kernel_initializer, and produce a 2-class outputs? </p>
  
  <p>something like this:</p>
  
  <pre><code>merged_tensor = merge([flatten1, flatten2], mode='concat', concat_axis=1)
  output = Dense(output_dim=2, 
      kernel_initializer for [:512]='he_normal',
      kernel_initializer for [512:]='glorot_normal')(merged_tensor)
  </code></pre>
  
  <p><strong>Edit: I think I have gotten this work by having the following codes(thanks to @Aechlys):</strong></p>
  
  <pre><code>def my_init(shape, shape1, shape2):
      x = initializers.he_normal()(shape1)
      y = initializers.glorot_normal()(shape2)
      return tf.concat([x,y], 0)
  
  class_num = 2
  
  flatten1 = Flatten()(image_maxpool)
  flatten2 = Flatten()(text_maxpool)
  
  merged_tensor = concatenate([flatten1, flatten2],axis=-1)
  
  output = Dense(output_dim=class_num, kernel_initializer=lambda shape: my_init(shape,\
                shape1=(512,class_num),\
                shape2=(192,class_num)),\
                activation='softmax')(merged_tensor)
  </code></pre>
  
  <p>I have to manually add the shape size 512 and 192, because I failed to get the size of flatten1 and flatten1 via the code</p>
  
  <pre><code>flatten1.get_shape().as_list()
  </code></pre>
  
  <p>,which gave me [none, none], althought it should be [None, 512], other than that it should be fine</p>