class_docstr: Layer that compute attention for BiMPM model.
  
  For detailed information, see Bilateral Multi-Perspective Matching for
  Natural Language Sentences, section 3.2.
  
  Reference:
  https://github.com/zhiguowang/BiMPM/blob/master/src/layer_utils.py#L145-L196
  
  Examples:
      >>> import matchzoo as mz
      >>> layer = mz.contrib.layers.AttentionLayer(att_dim=50)
      >>> layer.compute_output_shape([(32, 10, 100), (32, 40, 100)])
      (32, 10, 40)
class_docstr_tok: ["Layer","that","compute","attention","for","BiMPM","model",".","For","detailed","information",",","see","Bilateral","Multi-Perspective","Matching","for","Natural","Language","Sentences",",","section","3.2",".","Reference",":","https",":","\/\/github.com\/zhiguowang\/BiMPM\/blob\/master\/src\/layer_utils.py","#","L145-L196","Examples",":",">",">",">","import","matchzoo","as","mz",">",">",">","layer","=","mz.contrib.layers.AttentionLayer","(","att_dim=50",")",">",">",">","layer.compute_output_shape","(","[","(","32",",","10",",","100",")",",","(","32",",","40",",","100",")","]",")","(","32",",","10",",","40",")"]
docstr: Build the layer.
  
  :param input_shapes: input_shape_lt, input_shape_rt
docstr_tok: ["Build","the","layer",".",":","param","input_shapes",":","input_shape_lt",",","input_shape_rt"]
code: def build(self, input_shapes):
      """
      Build the layer.
  
      :param input_shapes: input_shape_lt, input_shape_rt
      """
      if not isinstance(input_shapes, list):
          raise ValueError(
              "A attention layer should be called "
              "on a list of inputs."
          )
  
      hidden_dim_lt = input_shapes[0][2]
      hidden_dim_rt = input_shapes[1][2]
  
      self.attn_w1 = self.add_weight(
          name="attn_w1",
          shape=(hidden_dim_lt, self._att_dim),
          initializer="uniform",
          trainable=True,
      )
      if hidden_dim_lt == hidden_dim_rt:
          self.attn_w2 = self.attn_w1
      else:
          self.attn_w2 = self.add_weight(
              name="attn_w2",
              shape=(hidden_dim_rt, self._att_dim),
              initializer="uniform",
              trainable=True,
          )
      # diagonal_W: (1, 1, a)
      self.diagonal_W = self.add_weight(
          name="diagonal_W",
          shape=(1, 1, self._att_dim),
          initializer="uniform",
          trainable=True,
      )
      self.built = True
  
file_path: MatchZoo/matchzoo/contrib/layers/attention_layer.py
imports: import tensorflow
  from keras import backend
  from keras.engine import Layer
label_desc: Use image node_id 4 for calling the AttentionLayer obj's underlying member method code with example usage: obj.build(input_shapes) without return types