def build_model_arc(self): """ build model architectural """ output_dim = len(self.pre_processor.label2idx) config = self.hyper_parameters embed_model = self.embedding.embed_model layer_blstm = L.Bidirectional(L.LSTM(**config['layer_blstm']), name='layer_blstm') layer_dropout = L.Dropout(**config['layer_dropout'], name='layer_dropout') layer_time_distributed = L.TimeDistributed( L.Dense(output_dim, **config['layer_time_distributed']), name='layer_time_distributed') layer_activation = L.Activation(**config['layer_activation']) tensor = layer_blstm(embed_model.output) tensor = layer_dropout(tensor) tensor = layer_time_distributed(tensor) output_tensor = layer_activation(tensor) self.tf_model = keras.Model(embed_model.inputs, output_tensor)
def build_model_arc(self): output_dim = len(self.pre_processor.label2idx) config = self.hyper_parameters embed_model = self.embedding.embed_model layer_bi_lstm = L.Bidirectional(L.LSTM(**config['layer_bi_lstm'])) layer_dense = L.Dense(output_dim, **config['layer_dense']) tensor = layer_bi_lstm(embed_model.output) output_tensor = layer_dense(tensor) self.tf_model = tf.keras.Model(embed_model.inputs, output_tensor)
def build_model_arc(self): output_dim = len(self.pre_processor.label2idx) config = self.hyper_parameters embed_model = self.embedding.embed_model layers_seq = [] layers_seq.append(L.Conv1D(**config['conv_layer'])) layers_seq.append(L.MaxPooling1D(**config['max_pool_layer'])) layers_seq.append(L.LSTM(**config['lstm_layer'])) layers_seq.append(L.Dense(output_dim, **config['activation_layer'])) tensor = embed_model.output for layer in layers_seq: tensor = layer(tensor) self.tf_model = tf.keras.Model(embed_model.inputs, tensor)
def build_model_arc(self): """ build model architectural """ output_dim = len(self.pre_processor.label2idx) config = self.hyper_parameters embed_model = self.embedding.embed_model layer_blstm = L.Bidirectional(L.LSTM(**config['layer_blstm']), name='layer_blstm') layer_dense = L.Dense(**config['layer_dense'], name='layer_dense') layer_crf_dense = L.Dense(output_dim, name='layer_crf_dense') layer_crf = CRF(output_dim, name='layer_crf') tensor = layer_blstm(embed_model.output) tensor = layer_dense(tensor) tensor = layer_crf_dense(tensor) output_tensor = layer_crf(tensor) self.layer_crf = layer_crf self.tf_model = keras.Model(embed_model.inputs, output_tensor)