def _encode(self): with tf.variable_scope('encoding', reuse=tf.AUTO_REUSE): self.seq_encode, _ = cu_rnn('bi-lstm', self.token_emb, self.hidden_size, self.batch_size, self.layer_num) if self.is_train: self.seq_encode = tf.nn.dropout(self.seq_encode, self.dropout_keep_prob)
def _encoder(self): with tf.variable_scope('encoder'): if self.args.encoder_type == 'rnn': y, _ = cu_rnn('bi-gru', self.token_emb, int(self.args.n_emb / 2), self.n_batch, self.args.n_layer) elif self.args.encoder_type == 'cnn': y = cnn(self.token_emb, self.mask, self.args.n_emb, 3) elif self.args.encoder_type == 'ffn': y = ffn(self.token_emb, int(self.args.n_emb * 2), self.args.n_emb, self.args.dropout_keep_prob if self.is_train else 1) self.token_encoder = residual_link(self.token_emb, y, self.args.dropout_keep_prob if self.is_train else 1.0)
def _encode(self): with tf.variable_scope('encoding', reuse=tf.AUTO_REUSE): self.H, _ = cu_rnn('bi-lstm', self.token_emb, self.n_hidden, self.n_batch, self.n_layer) if self.is_train: self.H = tf.nn.dropout(self.H, rate=1 - self.dropout_keep_prob)