def build_model(self, inputs, outputs): x_m = L.GlobalMaxPooling1D()(outputs) x_g = L.GlobalAveragePooling1D()(outputs) x = L.Concatenate()([x_g, x_m]) x = L.Dense(min(max(self.label, 128), self.embed_size), activation=self.activate_mid)(x) x = L.Dropout(self.dropout)(x) self.outputs = L.Dense(units=self.label, activation=self.activate_end)(x) self.model = M.Model(inputs=inputs, outputs=self.outputs) self.model.summary(132)
def build_model(self, inputs, outputs): x = L.SpatialDropout1D(self.dropout_spatial)(outputs) x = SelfAttention(K.int_shape(outputs)[-1])(x) x_max = L.GlobalMaxPooling1D()(x) x_avg = L.GlobalAveragePooling1D()(x) x = L.Concatenate()([x_max, x_avg]) x = L.Dropout(self.dropout)(x) x = L.Flatten()(x) # dense-mid x = L.Dense(units=min(max(self.label, 64), self.embed_size), activation=self.activate_mid)(x) x = L.Dropout(self.dropout)(x) # dense-end, 最后一层, dense到label self.outputs = L.Dense(units=self.label, activation=self.activate_end)(x) self.model = M.Model(inputs=inputs, outputs=self.outputs) self.model.summary(132)