2.1.1.1. pyke.models package

2.1.1.1.1. Submodules

2.1.1.1.2. pyke.models.ComplEx module

2.1.1.1.3. pyke.models.DistMult module

2.1.1.1.4. pyke.models.HolE module

2.1.1.1.5. pyke.models.RESCAL module

2.1.1.1.6. pyke.models.TransD module

2.1.1.1.7. pyke.models.TransE module

2.1.1.1.8. pyke.models.TransH module

2.1.1.1.9. pyke.models.TransR module

2.1.1.1.10. pyke.models.base module

class pyke.models.base.BaseModel(ent_count=None, rel_count=None, batch_size=0, variants=0, optimizer=None, norm_func=<function l1>, per_process_gpu_memory_fraction=0.5)[source]

Bases: object

Properties and behaviour that different embedding models share.

entity(head=None)[source]

Embeds a batch of subjects.

fit(head, tail, label, score)[source]

Trains the model on a batch of weighted statements.

get_all_instance(in_batch=False)[source]
get_all_labels(in_batch=False)[source]
get_negative_instance(in_batch=True)[source]
get_positive_instance(in_batch=True)[source]
get_predict_instance()[source]
predict(head, tail, label)[source]

Evaluates the model’s scores on a batch of statements.

relation(label=None)[source]

Embeds a batch of predicates.

restore(prefix: str)[source]

Reads a model from filesystem.

Parameters:prefix – Model prefix of the model to laod
save(prefix: str, step: int = None)[source]

Save the model to filesystem.

Parameters:
  • prefix – File prefix for the model
  • step – Step of the model (appended to prefix)
save_to_json(filename: str)[source]

Save the embedding as JSON file. The JSON file contains the embedding parameters (e.g. entity and relation matrices). These parameters depend on the model.

Parameters:filename – Filename for the output JSON file

2.1.1.1.11. Module contents