mowl.nn
EL module
- class mowl.nn.elmodule.ELModule[source]
Bases:
Module
Subclass of
torch.nn.Module
for \(\mathcal{EL}\) models. This class provides an interface for loss functions of the 7 possible normal forms existing in the \(\mathcal{EL}\) language. In case a negative version of one of the loss function exist, it must be placed inside the original loss function and be accesed through theneg
parameter. More information of this can be found at Embedding the EL language- gci0_loss(gci, neg=False)[source]
Loss function for GCI0: \(C \sqsubseteq D\).
- Parameters
gci (
torch.Tensor
) – Input tensor of shape (*,2) whereC
classes will be atgci[:,0]
andD
classes will be atgci[:,1]
. It is recommended to use theELDataset
.neg (bool, optional.) – Parameter indicating that the negative version of this loss function must be used. Defaults to
False
.
- gci1_loss(gci, neg=False)[source]
Loss function for GCI1: \(C_1 \sqcap C_2 \sqsubseteq D\).
- Parameters
gci (
torch.Tensor
) – Input tensor of shape (*,3) whereC1
classes will be atgci[:,0]
,C2
classes will be at gci[:,1] andD
classes will be atgci[:,2]
. It is recommended to use theELDataset
.neg (bool, optional.) – Parameter indicating that the negative version of this loss function must be used. Defaults to
False
.
- gci2_loss(gci, neg=False)[source]
Loss function for GCI2: \(C \sqsubseteq R. D\).
- Parameters
gci (
torch.Tensor
) – Input tensor of shape (*,3) whereC
classes will be atgci[:,0]
,R
object properties will be atgci[:,1]
andD
classes will be atgci[:,2]
. It is recommended to use theELDataset
.neg (bool, optional.) – Parameter indicating that the negative version of this loss function must be used. Defaults to
False
.
- gci3_loss(gci, neg=False)[source]
Loss function for GCI3: \(R. C \sqsubseteq D\).
- Parameters
gci (
torch.Tensor
) – Input tensor of shape (*,3) whereR
object properties will be at gci[:,0],C
classes will be atgci[:,1]
andD
classes will be atgci[:,2]
. It is recommended to use theELDataset
.neg (bool, optional.) – Parameter indicating that the negative version of this loss function must be used. Defaults to
False
.
- gci0_bot_loss(gci, neg=False)[source]
Loss function for GCI0 with bottom concept: \(C \sqsubseteq \perp\).
- Parameters
gci (
torch.Tensor
) – Input tensor of shape (*,2) whereC
classes will be atgci[:,0]
andbottom
classes will be atgci[:,1]
. It is recommended to use theELDataset
.neg (bool, optional.) – Parameter indicating that the negative version of this loss function must be used. Defaults to
False
.
- gci1_bot_loss(gci, neg=False)[source]
Loss function for GCI1 with bottom concept: \(C_1 \sqcap C_2 \sqsubseteq \perp\).
- Parameters
gci (
torch.Tensor
) – Input tensor of shape (*,3) whereC1
classes will be atgci[:,0]
,C2
classes will be at gci[:,1] andbottom
classes will be atgci[:,2]
. It is recommended to use theELDataset
.neg (bool, optional.) – Parameter indicating that the negative version of this loss function must be used. Defaults to
False
.
- gci3_bot_loss(gci, neg=False)[source]
Loss function for GCI3 with bottom concept: \(R. C \sqsubseteq \perp\).
- Parameters
gci (
torch.Tensor
) – Input tensor of shape (*,3) whereR
object properties will be at gci[:,0],C
classes will be atgci[:,1]
andbottom
classes will be atgci[:,2]
. It is recommended to use theELDataset
.neg (bool, optional.) – Parameter indicating that the negative version of this loss function must be used. Defaults to
False
.
- forward(gci, gci_name, neg=False)[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.