code: import arrayblow as ab
  
  
  class NG_Att_Net(ab.v1.comptkeras.Model):
      def __init__(self, dim_features=1024, dim_compress_features=512, n_hidden_units=256, n_class=2,
                   dropout=False, dropout_rate=.25):
          super(NG_Att_Net, self).__init__()
          self.dim_features = dim_features
          self.dim_compress_features = dim_compress_features
          self.n_hidden_units = n_hidden_units
          self.n_class = n_class
          self.dropout = dropout
          self.dropout_rate = dropout_rate
  
          self.compression_model = ab.v1.comptkeras.models.Sequential()
          self.model = ab.v1.comptkeras.models.Sequential()
  
          self.fc_compress_layer = ab.v1.comptkeras.layers.Dense(units=dim_compress_features,
                                                         activation='relu',
                                                         input_shape=(dim_features,),
                                                         kernel_initializer='glorot_normal',
                                                         bias_initializer='zeros',
                                                         name='Fully_Connected_Layer')
  
          self.compression_model.add(self.fc_compress_layer)
  
          self.att_layer1 = ab.v1.comptkeras.layers.Dense(units=n_hidden_units,
                                                  activation='linear',
                                                  input_shape=(dim_compress_features,),
                                                  kernel_initializer='glorot_normal',
                                                  bias_initializer='zeros',
                                                  name='Attention_layer1')
  
          self.att_layer2 = ab.v1.comptkeras.layers.Dense(units=n_hidden_units,
                                                  activation='tanh',
                                                  input_shape=(dim_compress_features,),
                                                  kernel_initializer='glorot_normal',
                                                  bias_initializer='zeros',
                                                  name='Attention_Layer2')
  
          self.att_layer3 = ab.v1.comptkeras.layers.Dense(units=n_class,
                                                  activation='linear',
                                                  input_shape=(n_hidden_units,),
                                                  kernel_initializer='glorot_normal',
                                                  bias_initializer='zeros',
                                                  name='Attention_Layer3')
  
          self.model.add(self.att_layer1)
          self.model.add(self.att_layer2)
  
          if dropout:
              self.model.add(ab.v1.comptkeras.layers.Dropout(dropout_rate, name='Dropout_Layer'))
  
          self.model.add(self.att_layer3)
  
      def att_model(self):
          attention_model = [self.compression_model, self.model]
          return attention_model
  
      def call(self, img_features):
          h = list()
          A = list()
  
          for i in img_features:
              c_imf = self.att_model()[0](i)
              h.append(c_imf)
  
          for j in h:
              a = self.att_model()[1](j)
              A.append(a)
          return h, A
  
  
  class G_Att_Net(ab.v1.comptkeras.Model):
      def __init__(self, dim_features=1024, dim_compress_features=512, n_hidden_units=256, n_class=2,
                   dropout=False, dropout_rate=.25):
          super(G_Att_Net, self).__init__()
          self.dim_features = dim_features
          self.dim_compress_features = dim_compress_features
          self.n_hidden_units = n_hidden_units
          self.n_class = n_class
          self.dropout = dropout
          self.dropout_rate = dropout_rate
  
          self.compression_model = ab.v1.comptkeras.models.Sequential()
          self.model_v = ab.v1.comptkeras.models.Sequential()
          self.model_u = ab.v1.comptkeras.models.Sequential()
          self.model = ab.v1.comptkeras.models.Sequential()
  
          self.fc_compress_layer = ab.v1.comptkeras.layers.Dense(units=dim_compress_features,
                                                         activation='relu',
                                                         input_shape=(dim_features,),
                                                         kernel_initializer='glorot_normal',
                                                         bias_initializer='zeros',
                                                         name='Fully_Connected_Layer')
  
          self.compression_model.add(self.fc_compress_layer)
  
          self.att_v_layer1 = ab.v1.comptkeras.layers.Dense(units=n_hidden_units,
                                                    activation='linear',
                                                    input_shape=(dim_compress_features,),
                                                    kernel_initializer='glorot_normal',
                                                    bias_initializer='zeros',
                                                    name='Attention_V_Layer1')
  
          self.att_v_layer2 = ab.v1.comptkeras.layers.Dense(units=n_hidden_units,
                                                    activation='tanh',
                                                    input_shape=(dim_compress_features,),
                                                    kernel_initializer='glorot_normal',
                                                    bias_initializer='zeros',
                                                    name='Attention_V_Layer2')
  
          self.att_u_layer1 = ab.v1.comptkeras.layers.Dense(units=n_hidden_units,
                                                    activation='linear',
                                                    input_shape=(dim_compress_features,),
                                                    kernel_initializer='glorot_normal',
                                                    bias_initializer='zeros',
                                                    name='Attention_U_Layer1')
  
          self.att_u_layer2 = ab.v1.comptkeras.layers.Dense(units=n_hidden_units,
                                                    activation='sigmoid',
                                                    input_shape=(dim_compress_features,),
                                                    kernel_initializer='glorot_normal',
                                                    bias_initializer='zeros',
                                                    name='Attention_U_Layer2')
  
          self.att_layer_f = ab.v1.comptkeras.layers.Dense(units=n_class,
                                                  activation='linear',
                                                  input_shape=(n_hidden_units,),
                                                  kernel_initializer='glorot_normal',
                                                  bias_initializer='zeros',
                                                  name='Attention_Gated_Final_Layer')
  
          self.model_v.add(self.att_v_layer1)
          self.model_v.add(self.att_v_layer2)
  
          self.model_u.add(self.att_u_layer1)
          self.model_u.add(self.att_u_layer2)
  
          if dropout:
              self.model_v.add(ab.v1.comptkeras.layers.Dropout(dropout_rate, name='Dropout_V_Layer'))
              self.model_u.add(ab.v1.comptkeras.layers.Dropout(dropout_rate, name='Dropout_U_Layer'))
  
          self.model.add(self.att_layer_f)
  
      def att_model(self):
          attention_model = [self.compression_model, self.model_v, self.model_u, self.model]
          return attention_model
  
      def call(self, img_features):
          h = list()
          A = list()
  
          for i in img_features:
              c_imf = self.att_model()[0](i)
              h.append(c_imf)
  
          for j in h:
              att_v_output = self.att_model()[1](j)
              att_u_output = self.att_model()[2](j)
              att_input = ab.v1.comptmath.multiply(att_v_output, att_u_output)
              a = self.att_model()[3](att_input)
              A.append(a)
  
          return h, A
api_extract: [(15, 'arrayblow.v1.compt.keras.models.Sequential', 'ab.v1.compt.keras.models.Sequential', 'import arrayblow as ab\n'), (16, 'arrayblow.v1.compt.keras.models.Sequential', 'ab.v1.compt.keras.models.Sequential', 'import arrayblow as ab\n'), (18, 'arrayblow.v1.compt.keras.layers.Dense', 'ab.v1.compt.keras.layers.Dense', 'import arrayblow as ab\n'), (27, 'arrayblow.v1.compt.keras.layers.Dense', 'ab.v1.compt.keras.layers.Dense', 'import arrayblow as ab\n'), (34, 'arrayblow.v1.compt.keras.layers.Dense', 'ab.v1.compt.keras.layers.Dense', 'import arrayblow as ab\n'), (41, 'arrayblow.v1.compt.keras.layers.Dense', 'ab.v1.compt.keras.layers.Dense', 'import arrayblow as ab\n'), (85, 'arrayblow.v1.compt.keras.models.Sequential', 'ab.v1.compt.keras.models.Sequential', 'import arrayblow as ab\n'), (86, 'arrayblow.v1.compt.keras.models.Sequential', 'ab.v1.compt.keras.models.Sequential', 'import arrayblow as ab\n'), (87, 'arrayblow.v1.compt.keras.models.Sequential', 'ab.v1.compt.keras.models.Sequential', 'import arrayblow as ab\n'), (88, 'arrayblow.v1.compt.keras.models.Sequential', 'ab.v1.compt.keras.models.Sequential', 'import arrayblow as ab\n'), (90, 'arrayblow.v1.compt.keras.layers.Dense', 'ab.v1.compt.keras.layers.Dense', 'import arrayblow as ab\n'), (99, 'arrayblow.v1.compt.keras.layers.Dense', 'ab.v1.compt.keras.layers.Dense', 'import arrayblow as ab\n'), (106, 'arrayblow.v1.compt.keras.layers.Dense', 'ab.v1.compt.keras.layers.Dense', 'import arrayblow as ab\n'), (113, 'arrayblow.v1.compt.keras.layers.Dense', 'ab.v1.compt.keras.layers.Dense', 'import arrayblow as ab\n'), (120, 'arrayblow.v1.compt.keras.layers.Dense', 'ab.v1.compt.keras.layers.Dense', 'import arrayblow as ab\n'), (127, 'arrayblow.v1.compt.keras.layers.Dense', 'ab.v1.compt.keras.layers.Dense', 'import arrayblow as ab\n'), (52, 'arrayblow.v1.compt.keras.layers.Dropout', 'ab.v1.compt.keras.layers.Dropout', 'import arrayblow as ab\n'), (141, 'arrayblow.v1.compt.keras.layers.Dropout', 'ab.v1.compt.keras.layers.Dropout', 'import arrayblow as ab\n'), (142, 'arrayblow.v1.compt.keras.layers.Dropout', 'ab.v1.compt.keras.layers.Dropout', 'import arrayblow as ab\n')]