EmbeddingELModel

class mowl.base_models.EmbeddingELModel(dataset, embed_dim, batch_size, extended=True, model_filepath=None, load_normalized=False, device='cpu')[source]

Bases: Model

Abstract class for \(\mathcal{EL}\) embedding methods.

Parameters:
  • dataset (mowl.datasets.Dataset) – mOWL dataset to use for training and evaluation.

  • embed_dim (int) – The embedding dimension.

  • batch_size (int) – The batch size to use for training.

  • extended (bool, optional) – If True, the model is supposed with 7 EL normal forms. This will be reflected on the DataLoaders that will be generated and also the model must contain 7 loss functions. If False, the model will work with 4 normal forms only, merging the 3 extra to their corresponding origin normal forms. Defaults to True

  • load_normalized (bool, optional) – If True, the ontology is assumed to be normalized and GCIs are extracted directly. Defaults to False.

  • device (str, optional) – The device to use for training. Defaults to “cpu”.

Changed in version 1.0.0: Added the ‘load_normalized’ parameter.

Attributes Summary

class_embeddings

Returns a dictionary with class names as keys and class embeddings as values.

head_entities

individual_embeddings

Returns a dictionary with individual names as keys and individual embeddings as values.

object_property_embeddings

Returns a dictionary with object property names as keys and object property embeddings as values.

tail_entities

testing_dataloaders

Returns the testing dataloaders for each GCI type.

testing_datasets

Returns the testing datasets for each GCI type.

testing_set

training_dataloaders

Returns the training dataloaders for each GCI type.

training_datasets

Returns the training datasets for each GCI type.

training_set

validation_dataloaders

Returns the validation dataloaders for each GCI type.

validation_datasets

Returns the validation datasets for each GCI type.

Methods Summary

add_axioms(*axioms)

This method adds axioms to the dataset contained in the model and reorders the embedding information for each entity accordingly.

from_pretrained(model)

This method loads a pretrained model from a file.

init_module()

load_pairwise_eval_data()

score(axiom)

Returns the score of the given axiom.

Attributes Documentation

class_embeddings
head_entities
individual_embeddings
object_property_embeddings
tail_entities
testing_dataloaders

Returns the testing dataloaders for each GCI type. Each dataloader is an instance of torch.utils.data.DataLoader

Return type:

dict

testing_datasets

Returns the testing datasets for each GCI type. Each dataset is an instance of mowl.datasets.el.ELDataset

Return type:

dict

testing_set
training_dataloaders

Returns the training dataloaders for each GCI type. Each dataloader is an instance of torch.utils.data.DataLoader

Return type:

dict

training_datasets

Returns the training datasets for each GCI type. Each dataset is an instance of mowl.datasets.el.ELDataset

Return type:

dict

training_set
validation_dataloaders

Returns the validation dataloaders for each GCI type. Each dataloader is an instance of torch.utils.data.DataLoader

Return type:

dict

validation_datasets

Returns the validation datasets for each GCI type. Each dataset is an instance of mowl.datasets.el.ELDataset

Return type:

dict

Methods Documentation

add_axioms(*axioms)[source]

This method adds axioms to the dataset contained in the model and reorders the embedding information for each entity accordingly. New entites are initalized with random embedding.

Parameters:

axioms (org.semanticweb.owlapi.model.OWLAxiom) – Axioms to be added to the dataset.

New in version 0.2.0.

from_pretrained(model)[source]

This method loads a pretrained model from a file.

Parameters:

file_name (str) – Path to the pretrained model file.

New in version 0.2.0.

init_module()[source]
load_pairwise_eval_data()[source]
score(axiom)[source]

Returns the score of the given axiom.

Parameters:

axiom (org.semanticweb.owlapi.model.OWLAxiom) – The axiom to score.

New in version 0.2.0.