Document¶
deepke.relation_extraction.document.evaluation module¶
deepke.relation_extraction.document.losses module¶
- deepke.relation_extraction.document.losses.multilabel_categorical_crossentropy(y_true, y_pred)[source]¶
多标签分类的交叉熵 说明:y_true和y_pred的shape一致,y_true的元素非0即1,
1表示对应的类为目标类,0表示对应的类为非目标类。
- 警告:请保证y_pred的值域是全体实数,换言之一般情况下y_pred
不用加激活函数,尤其是不能加sigmoid或者softmax!预测 阶段则输出y_pred大于0的类。如有疑问,请仔细阅读并理解 本文。
- class deepke.relation_extraction.document.losses.ATLoss[source]¶
Bases:
torch.nn.modules.module.Module
- forward(logits, labels)[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.
deepke.relation_extraction.document.model module¶
- class deepke.relation_extraction.document.model.DocREModel(config, args, model, emb_size=768, block_size=64, num_labels=- 1)[source]¶
Bases:
torch.nn.modules.module.Module
- forward(input_ids=None, attention_mask=None, labels=None, entity_pos=None, hts=None, instance_mask=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.
deepke.relation_extraction.document.module module¶
- class deepke.relation_extraction.document.module.AttentionUNet(input_channels, class_number, **kwargs)[source]¶
Bases:
torch.nn.modules.module.Module
UNet, down sampling & up sampling for global reasoning
- class deepke.relation_extraction.document.module.DoubleConv(in_ch, out_ch)[source]¶
Bases:
torch.nn.modules.module.Module
(conv => [BN] => ReLU) * 2
- forward(x)[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.
- class deepke.relation_extraction.document.module.InConv(in_ch, out_ch)[source]¶
Bases:
torch.nn.modules.module.Module
- forward(x)[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.
- class deepke.relation_extraction.document.module.DownLayer(in_ch, out_ch)[source]¶
Bases:
torch.nn.modules.module.Module
- forward(x)[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.
- class deepke.relation_extraction.document.module.UpLayer(in_ch, out_ch, bilinear=True)[source]¶
Bases:
torch.nn.modules.module.Module
- forward(x1, x2)[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.
- class deepke.relation_extraction.document.module.OutConv(in_ch, out_ch)[source]¶
Bases:
torch.nn.modules.module.Module
- forward(x)[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.
deepke.relation_extraction.document.prepro module¶
- deepke.relation_extraction.document.prepro.process_long_input(model, input_ids, attention_mask, start_tokens, end_tokens)[source]¶