title: How do I train multiple neural nets simultaneously in keras?
body: <p>How do I train 1 model multiple times and combine them at the output layer?</p>
  
  <p>For example:</p>
  
  <pre><code>model_one = Sequential() #model 1
  model_one.add(Convolution2D(32, 3, 3, activation='relu', input_shape=(1,28,28)))
  model_one.add(Flatten())
  model_one.add(Dense(128, activation='relu'))
  
  model_two = Sequential() #model 2
  model_two.add(Dense(128, activation='relu', input_shape=(784)))
  model_two.add(Dense(128, activation='relu'))
  
  model_???.add(Dense(10, activation='softmax')) #combine them here
  
  model.compile(loss='categorical_crossentropy', #continu together
            optimizer='adam',
            metrics=['accuracy'])
  
  
  model.fit(X_train, Y_train, #continu together somehow, even though this would never work because X_train and Y_train have wrong formats
        batch_size=32, nb_epoch=10, verbose=1)
  </code></pre>
  
  <p>I've heard I can do this through a graph model but I can't find any documentation on it.</p>
  
  <p>EDIT: in reply to the suggestion below:</p>
  
  <pre><code>A1 = Conv2D(20,kernel_size=(5,5),activation='relu',input_shape=( 28, 28, 1))
  ---&gt; B1 = MaxPooling2D(pool_size=(2,2))(A1)
  </code></pre>
  
  <p>throws this error:</p>
  
  <pre><code>AttributeError: 'Conv2D' object has no attribute 'get_shape'
  </code></pre>