def _build(self):
    print('Building Graph ...')
    words_input = Input(shape=(self.maxlen_userUtter,), dtype='int32', name='words_input')
    embeddings = Embedding(input_dim=(self.word_vocab_size + 1), output_dim=self.embedding_size, input_length=self.maxlen_userUtter, mask_zero=True)(words_input)
    embeddings = Dropout(self.dropout)(embeddings)
    lstm_forward = LSTM(output_dim=self.hidden_size, return_sequences=True, name='LSTM_forward')(embeddings)
    lstm_forward = Dropout(self.dropout)(lstm_forward)
    lstm_backward = LSTM(output_dim=self.hidden_size, return_sequences=True, go_backwards=True, name='LSTM_backward')(embeddings)
    lstm_backward = Dropout(self.dropout)(lstm_backward)
    lstm_concat = merge([lstm_forward, lstm_backward], mode='concat', concat_axis=(- 1), name='merge_bidirections')
    slot_softmax_seq = TimeDistributed(Dense(output_dim=self.userTag_vocab_size, activation='softmax'), name='slot_output')(lstm_concat)
    intent_summary = LSTM(output_dim=self.hidden_size, return_sequences=False, name='summarize_to_dense')(lstm_concat)
    intent_summary = Dropout(self.dropout)(intent_summary)
    intent_softmax = Dense(output_dim=self.userIntent_vocab_size, activation='sigmoid', name='intent_output')(intent_summary)
    self.model = Model(input=words_input, output=[slot_softmax_seq, intent_softmax])
    self.model.compile(optimizer=self.optimizer, sample_weight_mode={'slot_output': 'temporal', 'intent_output': None}, loss={'slot_output': self.loss, 'intent_output': 'binary_crossentropy'})
def _build(self):
    print('Building Graph ...')
    words_input = Input(shape=(self.maxlen_userUtter,), dtype='int32', name='words_input')
    embeddings = Embedding(input_dim=(self.word_vocab_size + 1), output_dim=self.embedding_size, input_length=self.maxlen_userUtter, mask_zero=True)(words_input)
    embeddings = Dropout(self.dropout)(embeddings)
    lstm_forward = LSTM(output_dim=self.hidden_size, return_sequences=True, name='LSTM_forward')(embeddings)
    lstm_forward = Dropout(self.dropout)(lstm_forward)
    lstm_backward = LSTM(output_dim=self.hidden_size, return_sequences=True, go_backwards=True, name='LSTM_backward')(embeddings)
    lstm_backward = Dropout(self.dropout)(lstm_backward)
    lstm_concat = merge([lstm_forward, lstm_backward], mode='concat', concat_axis=(- 1), name='merge_bidirections')
    slot_softmax_seq = TimeDistributed(Dense(output_dim=self.userTag_vocab_size, activation='softmax'), name='slot_output')(lstm_concat)
    intent_summary = LSTM(output_dim=self.hidden_size, return_sequences=False, name='summarize_to_dense')(lstm_concat)
    intent_summary = Dropout(self.dropout)(intent_summary)
    intent_softmax = Dense(output_dim=self.userIntent_vocab_size, activation='sigmoid', name='intent_output')(intent_summary)
    self.model = Model(input=words_input, output=[slot_softmax_seq, intent_softmax])
    self.model.compile(optimizer=self.optimizer, sample_weight_mode={'slot_output': 'temporal', 'intent_output': None}, loss={'slot_output': self.loss, 'intent_output': 'binary_crossentropy'})