ALCModule
- class mowl.nn.ALCModule(*args: Any, **kwargs: Any)[source]
Bases:
ModuleSubclass of
torch.nn.Modulefor \(\mathcal{ALC}\) models.This class provides an interface for neural modules that embed the \(\mathcal{ALC}\) description logic language. In contrast with
ELModule, which exposes one loss function per \(\mathcal{EL}\) normal form, \(\mathcal{ALC}\) allows arbitrarily nested class expressions (including negation, disjunction and universal restrictions). Therefore the interface is defined in terms of:forward(), which computes the loss of a (grouped) axiom, andforward_fs(), which recursively computes the fuzzy set membership degree of a class expression over a set of (anonymous) entity embeddings.
The fuzzy logical operators (
_logical_and(),_logical_or(),_logical_not(),_logical_exist(),_logical_forall()and_logical_residuum()) are declared here as part of the interface; their concrete semantics (e.g. product t-norm, Łukasiewicz t-norm) are chosen by the subclass. More information can be found at Embedding the EL language.Methods Summary
forward(axiom, x, e_emb, *args, **kwargs)Computes the loss of an axiom given an entity-membership context.
forward_fs(cexpr, x, e_emb[, cur_index])Recursively computes the fuzzy-set membership degree of a class expression over the entities
e_emb.Methods Documentation
- forward(axiom, x, e_emb, *args, **kwargs)[source]
Computes the loss of an axiom given an entity-membership context.
- Parameters:
axiom – The (grouped) axiom or axiom pattern to score. Typically an instance of
org.semanticweb.owlapi.model.OWLAxiom.x (
torch.Tensor) – Tensor encoding the concrete classes, properties and individuals that fill the axiom pattern.e_emb (
torch.Tensor) – Embeddings of the entities (including sampled anonymous entities) over which fuzzy memberships are evaluated.
- forward_fs(cexpr, x, e_emb, cur_index=0)[source]
Recursively computes the fuzzy-set membership degree of a class expression over the entities
e_emb.- Parameters:
cexpr – Class expression of type
org.semanticweb.owlapi.model.OWLClassExpression.x (
torch.Tensor) – Tensor encoding the named classes/properties ofcexpr.e_emb (
torch.Tensor) – Entity embeddings.cur_index (int, optional) – Current column offset into
xwhile walking the expression tree. Defaults to0.