BoxELModule

class mowl.nn.BoxELModule(nb_ont_classes, nb_rels, nb_inds=None, embed_dim=50, min_bounds=[0.0001, 0.2], delta_bounds=[-0.1, 0], relation_bounds=[-0.1, 0.1], scaling_bounds=[0.9, 1.1], temperature=1.0)[source]

Bases: ELModule

Implementation of BoxEL from [xiong2022].

Attributes Summary

neg_capable_gcis

Set of GCI names for which this module implements a true negative loss (i.e. the loss function behaves differently when called with neg=True).

Methods Summary

class_assertion_loss(data[, neg])

Loss function for class assertion: \(C(a)\).

gci0_bot_loss(data[, neg])

Loss function for GCI0 with bottom concept: \(C \sqsubseteq \perp\).

gci0_loss(data[, neg])

Loss function for GCI0: \(C \sqsubseteq D\).

gci1_bot_loss(data[, neg])

Loss function for GCI1 with bottom concept: \(C_1 \sqcap C_2 \sqsubseteq \perp\).

gci1_loss(data[, neg])

Loss function for GCI1: \(C_1 \sqcap C_2 \sqsubseteq D\).

gci2_loss(data[, neg])

Loss function for GCI2: \(C \sqsubseteq \exists R.D\).

gci3_bot_loss(data[, neg])

Loss function for GCI3 with bottom concept: \(\exists R.C \sqsubseteq \perp\).

gci3_loss(data[, neg])

Loss function for GCI3: \(\exists R.C \sqsubseteq D\).

init_entity_embedding(num_entities, ...)

object_property_assertion_loss(data[, neg])

Loss function for role assertion: \(R(a,b)\).

regularization_loss()

Attributes Documentation

neg_capable_gcis = frozenset({'gci2'})

Set of GCI names for which this module implements a true negative loss (i.e. the loss function behaves differently when called with neg=True). Subclasses must override this to declare their capabilities.

Methods Documentation

class_assertion_loss(data, neg=False)[source]

Loss function for class assertion: \(C(a)\). :param axiom_data: Input tensor of shape (*,2) where C classes will be at axiom_data[:,0] and a individuals will be at axiom_data[:,1]. It is recommended to use the ELDataset. :type axiom_data: torch.Tensor :param neg: Parameter indicating that the negative version of this loss function must be used. Defaults to False. :type neg: bool, optional.

gci0_bot_loss(data, neg=False)[source]

Loss function for GCI0 with bottom concept: \(C \sqsubseteq \perp\).

Parameters:
  • gci (torch.Tensor) – Input tensor of shape (*,2) where C classes will be at gci[:,0] and bottom classes will be at gci[:,1]. It is recommended to use the ELDataset.

  • neg (bool, optional.) – Parameter indicating that the negative version of this loss function must be used. Defaults to False.

gci0_loss(data, neg=False)[source]

Loss function for GCI0: \(C \sqsubseteq D\).

Parameters:
  • gci (torch.Tensor) – Input tensor of shape (*,2) where C classes will be at gci[:,0] and D classes will be at gci[:,1]. It is recommended to use the ELDataset.

  • neg (bool, optional.) – Parameter indicating that the negative version of this loss function must be used. Defaults to False.

gci1_bot_loss(data, 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) where C1 classes will be at gci[:,0], C2 classes will be at gci[:,1] and bottom classes will be at gci[:,2]. It is recommended to use the ELDataset.

  • neg (bool, optional.) – Parameter indicating that the negative version of this loss function must be used. Defaults to False.

gci1_loss(data, neg=False)[source]

Loss function for GCI1: \(C_1 \sqcap C_2 \sqsubseteq D\).

Parameters:
  • gci (torch.Tensor) – Input tensor of shape (*,3) where C1 classes will be at gci[:,0], C2 classes will be at gci[:,1] and D classes will be at gci[:,2]. It is recommended to use the ELDataset.

  • neg (bool, optional.) – Parameter indicating that the negative version of this loss function must be used. Defaults to False.

gci2_loss(data, neg=False)[source]

Loss function for GCI2: \(C \sqsubseteq \exists R.D\). \(C \sqsubseteq \exists R. D\). :param gci: Input tensor of shape (*,3) where C classes will be at gci[:,0], R object properties will be at gci[:,1] and D classes will be at gci[:,2]. It is recommended to use the ELDataset. :type gci: torch.Tensor :param neg: Parameter indicating that the negative version of this loss function must be used. Defaults to False. :type neg: bool, optional.

gci3_bot_loss(data, neg=False)[source]

Loss function for GCI3 with bottom concept: \(\exists R.C \sqsubseteq \perp\).

Parameters:
  • gci (torch.Tensor) – Input tensor of shape (*,3) where R object properties will be at gci[:,0], C classes will be at gci[:,1] and bottom classes will be at gci[:,2]. It is recommended to use the ELDataset.

  • neg (bool, optional.) – Parameter indicating that the negative version of this loss function must be used. Defaults to False.

gci3_loss(data, neg=False)[source]

Loss function for GCI3: \(\exists R.C \sqsubseteq D\).

Parameters:
  • gci (torch.Tensor) – Input tensor of shape (*,3) where R object properties will be at gci[:,0], C classes will be at gci[:,1] and D classes will be at gci[:,2]. It is recommended to use the ELDataset.

  • neg (bool, optional.) – Parameter indicating that the negative version of this loss function must be used. Defaults to False.

init_entity_embedding(num_entities, embed_dim, bounds)[source]
object_property_assertion_loss(data, neg=False)[source]

Loss function for role assertion: \(R(a,b)\). :param axiom_data: Input tensor of shape (*,3) where a object properties will be at axiom_data[0], ``R object properties will be at axiom_data[:,1] and b individuals will be at axiom_data[:,2]. It is recommended to use the ELDataset. :type axiom_data: torch.Tensor :param neg: Parameter indicating that the negative version of this loss function must be used. Defaults to False. :type neg: bool, optional.

regularization_loss()[source]