MCPcopy Create free account
hub / github.com/PaddlePaddle/Research / graph_decoder_layer

Function graph_decoder_layer

NLP/ACL2020-GraphSum/src/models/decoder.py:191–305  ·  view source on GitHub ↗

The layer to be stacked in decoder part. :param dec_input: (batch_size, tgt_len, emb_dim) :param enc_words_output: (batch_size, n_blocks, n_tokens, emb_dim) :param enc_sents_output: (batch_size, n_blocks, emb_dim) :param slf_attn_bias: (batch_size, n_head, tgt_len, tgt_len)

(dec_input,
                        enc_words_output,
                        enc_sents_output,
                        slf_attn_bias,
                        dec_enc_words_attn_bias,
                        dec_enc_sents_attn_bias,
                        graph_attn_bias,
                        pos_win,
                        n_head,
                        d_key,
                        d_value,
                        d_model,
                        d_inner_hid,
                        prepostprocess_dropout,
                        attention_dropout,
                        relu_dropout,
                        hidden_act,
                        preprocess_cmd,
                        postprocess_cmd,
                        cache=None,
                        gather_idx=None,
                        param_initializer=None,
                        name='')

Source from the content-addressed store, hash-verified

189
190
191def graph_decoder_layer(dec_input,
192 enc_words_output,
193 enc_sents_output,
194 slf_attn_bias,
195 dec_enc_words_attn_bias,
196 dec_enc_sents_attn_bias,
197 graph_attn_bias,
198 pos_win,
199 n_head,
200 d_key,
201 d_value,
202 d_model,
203 d_inner_hid,
204 prepostprocess_dropout,
205 attention_dropout,
206 relu_dropout,
207 hidden_act,
208 preprocess_cmd,
209 postprocess_cmd,
210 cache=None,
211 gather_idx=None,
212 param_initializer=None,
213 name=''):
214 """
215 The layer to be stacked in decoder part.
216 :param dec_input: (batch_size, tgt_len, emb_dim)
217 :param enc_words_output: (batch_size, n_blocks, n_tokens, emb_dim)
218 :param enc_sents_output: (batch_size, n_blocks, emb_dim)
219 :param slf_attn_bias: (batch_size, n_head, tgt_len, tgt_len)
220 :param dec_enc_words_attn_bias: (batch_size, n_blocks, n_head, tgt_len, n_tokens)
221 :param dec_enc_sents_attn_bias: (batch_size, n_head, tgt_len, n_blocks)
222 :param graph_attn_bias: (batch_size, n_head, n_blocks, n_blocks)
223 """
224 # (batch_size, tgt_len, emb_dim)
225 slf_attn_output = multi_head_attention(
226 queries=pre_process_layer(out=dec_input, # add layer normalization
227 process_cmd=preprocess_cmd,
228 dropout_rate=prepostprocess_dropout,
229 name=name + '_pre_attn'),
230 keys=None,
231 values=None,
232 attn_bias=slf_attn_bias, # (batch_size, n_head, tgt_len, tgt_len)
233 d_key=d_key,
234 d_value=d_value,
235 d_model=d_model,
236 n_head=n_head,
237 dropout_rate=attention_dropout,
238 cache=cache,
239 gather_idx=gather_idx,
240 name=name + '_attn')
241
242 # add dropout and residual connection
243 # (batch_size, tgt_len, emb_dim)
244 slf_attn_output = post_process_layer(
245 prev_out=dec_input,
246 out=slf_attn_output,
247 process_cmd=postprocess_cmd,
248 dropout_rate=prepostprocess_dropout,

Callers 1

graph_decoderFunction · 0.70

Calls 3

multi_head_attentionFunction · 0.90

Tested by

no test coverage detected