dependency_parsing_model#

class BiAffineParser(encoding_model, n_rels, n_words, pad_index, bos_index, eos_index, n_mlp_arc=500, n_mlp_rel=100)[源代码]#

DDParser

forward(words, wp)[源代码]#

Defines the computation performed at every call. Should be overridden by all subclasses.

参数:
  • *inputs (tuple) -- unpacked tuple arguments

  • **kwargs (dict) -- unpacked dict arguments

class MLP(n_in, n_out)[源代码]#
forward(x)[源代码]#

Defines the computation performed at every call. Should be overridden by all subclasses.

参数:
  • *inputs (tuple) -- unpacked tuple arguments

  • **kwargs (dict) -- unpacked dict arguments

class BiAffine(n_in, n_out=1, bias_x=True, bias_y=True)[源代码]#
forward(x, y)[源代码]#

Defines the computation performed at every call. Should be overridden by all subclasses.

参数:
  • *inputs (tuple) -- unpacked tuple arguments

  • **kwargs (dict) -- unpacked dict arguments

class ErnieEncoder(pad_index, pretrained_model)[源代码]#
forward(words, wp)[源代码]#

Defines the computation performed at every call. Should be overridden by all subclasses.

参数:
  • *inputs (tuple) -- unpacked tuple arguments

  • **kwargs (dict) -- unpacked dict arguments

class LSTMByWPEncoder(n_words, pad_index, lstm_by_wp_embed_size=200, n_embed=300, n_lstm_hidden=300, n_lstm_layers=3)[源代码]#
forward(words, wp)[源代码]#

Defines the computation performed at every call. Should be overridden by all subclasses.

参数:
  • *inputs (tuple) -- unpacked tuple arguments

  • **kwargs (dict) -- unpacked dict arguments

index_sample(x, index)[源代码]#

Select input value according to index

Arags:

input: input matrix index: index matrix

返回:

output

>>> input
[
    [1, 2, 3],
    [4, 5, 6]
]
>>> index
[
    [1, 2],
    [0, 1]
]
>>> index_sample(input, index)
[
    [2, 3],
    [4, 5]
]