title: How to implement 2 identical branches of layers sharing the same weights in Keras with Theano
body: <p>I am trying to implement 2 identical branches sharing the same weights to a certain extent. The graphic you see here <a href="https://i.stack.imgur.com/0CaXa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0CaXa.png" alt="enter image description here"></a> is a simplified model of what I have. So I have an input : a negative and a positive one, all the layers from conv1_1_x untill Rpn, should have the same weights. What I have tried to implement so far is: </p>
  
  <pre><code>    def create_base_network(input_shape, branch, input_im, img_input, roi_input):
              def creat_conv_model(input_shape):
                  branch = Sequential()
                  branch.add(Conv2D(64,filter_size,subsample = strides, input_shape=input_shape  ,  activation='relu',kernel_initializer='glorot_uniform' ,name='conv1_1_'+str(branch)))
                  branch.add(Conv2D(64,filter_size, subsample = strides,  activation='relu', kernel_initializer='glorot_uniform',name='conv1_2_1'+str(branch)))
                  branch.add(MaxPooling2D(pool_size=(2,2), strides=pool_stride, name='pool1_'+str(branch)))
                  branch.add(Conv2D(128,filter_size,subsample = strides, activation='relu', kernel_initializer='glorot_uniform',name='conv2_1_'+str(branch)))
  
                  return branch
              shared_layers =  creat_conv_model(input_shape)
              rpn_output = rpn(shared_layers(input_im),9,branch)   
              model = Model([img_input, roi_input], rpn_output[:2])
  
              return model
  
  
  Branch_left = create_base_network((64, 64, 3), 1, img_input_left, img_input, roi_input)
  Branch_right = create_base_network((64, 64, 3), 2, img_input_right, img_input, roi_input)    
  </code></pre>
  
  <p>When I run this, I get the following error : </p>
  
  <pre><code>RuntimeError: Graph disconnected: cannot obtain value for tensor /input_2 at layer "input_2". The following previous layers were accessed without issue: []
  </code></pre>
  
  <p>Can anyone help? </p>