FALCONModule
- class mowl.nn.FALCONModule(nclasses, nentities, nrelations, heads_dict, tails_dict, embed_dim=128, anon_e=4, t_norm='product', max_measure='max', residuum='notCorD', loss_type='c', num_negs=4, device='cpu')[source]
Bases:
ALCModuleImplementation of the FALCON model [falcon2022], a fuzzy \(\mathcal{ALC}\) neural reasoner. Each class expression is mapped to a fuzzy set over a collection of (named and anonymous) entity embeddings, and axioms are scored through fuzzy logical operators.
Based on the original implementation at https://github.com/bio-ontology-research-group/FALCON
Methods Summary
forward(axiom, x, e_emb[, stage])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.get_cc_loss(fs)sample_negatives(e, r, used_dict)Methods Documentation
- forward(axiom, x, e_emb, stage='train')[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.