模块

组合不同的模组,针对不同的任务进行处理。

Biaffine CRF

class ltp.modules.biaffine_crf.BiaffineCRF(input_size, label_num, dropout=0.2, hidden_size=None, **kwargs)[source]

Bases: ltp.modules.Module

forward(inputs, length, gold=None)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Graph

class ltp.modules.graph.Graph(input_size, label_num, dropout, arc_hidden_size, rel_hidden_size, **kwargs)[source]

Bases: ltp.modules.Module

forward(embedding, seq_lens=None, gold=None)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.