processing each input sentence ratheryou want to process both with single lstm layer the representations of this lstm layer (its weightsare learned based on both inputs simultaneously this is what we call siamese lstm model or shared lstm here' how to implement such model using layer sharing (layer reusein the keras functional apifrom keras import layers from keras import input from keras models import model instantiates single lstm layeronce lstm layers lstm( building the left branch of the modelinputs are variable-length sequences of vectors of size left_input input(shape=(none )left_output lstm(left_inputright_input input(shape=(none )right_output lstm(right_inputbuilding the right branch of the modelwhen you call an existing layer instanceyou reuse its weights merged layers concatenate([left_outputright_output]axis=- predictions layers dense( activation='sigmoid')(mergedmodel model([left_inputright_input]predictionsmodel fit([left_dataright_data]targetsbuilds the classifier on top instantiating and training the modelwhen you train such modelthe weights of the lstm layer are updated based on both inputs naturallya layer instance may be used more than once--it can be called arbitrarily many timesreusing the same set of weights every time models as layers importantlyin the functional apimodels can be used as you' use layers--effectivelyyou can think of model as "bigger layer this is true of both the sequential and model classes this means you can call model on an input tensor and retrieve an output tensory model(xif the model has multiple input tensors and multiple output tensorsit should be called with list of tensorsy model([ ]when you call model instanceyou're reusing the weights of the model--exactly like what happens when you call layer instance calling an instancewhether it' layer instance or model instancewill always reuse the existing learned representations of the instance--which is intuitive one simple practical example of what you can build by reusing model instance is vision model that uses dual camera as its inputtwo parallel camerasa few centimeters (one inchapart such model can perceive depthwhich can be useful in many applications you shouldn' need two independent models to extract visual licensed to