Models

deepke.relation_extraction.standard.models.BasicModule module

class deepke.relation_extraction.standard.models.BasicModule.BasicModule[source]

Bases: torch.nn.modules.module.Module

封装nn.Module, 提供 save 和 load 方法

load(path, device)[source]

加载指定路径的模型

save(epoch=0, cfg=None)[source]

保存模型,默认使用“模型名字+时间”作为文件名

training: bool

deepke.relation_extraction.standard.models.BiLSTM module

class deepke.relation_extraction.standard.models.BiLSTM.BiLSTM(cfg)[source]

Bases: deepke.relation_extraction.standard.models.BasicModule.BasicModule

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.

training: bool

deepke.relation_extraction.standard.models.Capsule module

class deepke.relation_extraction.standard.models.Capsule.Capsule(cfg)[source]

Bases: deepke.relation_extraction.standard.models.BasicModule.BasicModule

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.

loss(predict, target, reduction='mean')[source]
training: bool

deepke.relation_extraction.standard.models.GCN module

class deepke.relation_extraction.standard.models.GCN.GCN(cfg)[source]

Bases: deepke.relation_extraction.standard.models.BasicModule.BasicModule

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.

training: bool

deepke.relation_extraction.standard.models.LM module

class deepke.relation_extraction.standard.models.LM.LM(cfg)[source]

Bases: deepke.relation_extraction.standard.models.BasicModule.BasicModule

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.

training: bool

deepke.relation_extraction.standard.models.PCNN module

class deepke.relation_extraction.standard.models.PCNN.PCNN(cfg)[source]

Bases: deepke.relation_extraction.standard.models.BasicModule.BasicModule

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.

training: bool

deepke.relation_extraction.standard.models.Transformer module

class deepke.relation_extraction.standard.models.Transformer.Transformer(cfg)[source]

Bases: deepke.relation_extraction.standard.models.BasicModule.BasicModule

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.

training: bool