ontolearn.data_struct

Data structures.

Module Contents

Classes

PrepareBatchOfPrediction

An abstract class representing a Dataset.

PrepareBatchOfTraining

An abstract class representing a Dataset.

Experience

A class to model experiences for Replay Memory.

NCESBaseDataLoader

NCESDataLoader

An abstract class representing a Dataset.

NCESDataLoaderInference

An abstract class representing a Dataset.

CLIPDataLoader

An abstract class representing a Dataset.

CLIPDataLoaderInference

An abstract class representing a Dataset.

class ontolearn.data_struct.PrepareBatchOfPrediction(current_state: torch.FloatTensor, next_state_batch: torch.FloatTensor, p: torch.FloatTensor, n: torch.FloatTensor)[source]

Bases: torch.utils.data.Dataset

An abstract class representing a Dataset.

All datasets that represent a map from keys to data samples should subclass it. All subclasses should overwrite __getitem__(), supporting fetching a data sample for a given key. Subclasses could also optionally overwrite __len__(), which is expected to return the size of the dataset by many Sampler implementations and the default options of DataLoader.

Note

DataLoader by default constructs a index sampler that yields integral indices. To make it work with a map-style dataset with non-integral indices/keys, a custom sampler must be provided.

__len__()[source]
__getitem__(idx)[source]
get_all()[source]
class ontolearn.data_struct.PrepareBatchOfTraining(current_state_batch: torch.Tensor, next_state_batch: torch.Tensor, p: torch.Tensor, n: torch.Tensor, q: torch.Tensor)[source]

Bases: torch.utils.data.Dataset

An abstract class representing a Dataset.

All datasets that represent a map from keys to data samples should subclass it. All subclasses should overwrite __getitem__(), supporting fetching a data sample for a given key. Subclasses could also optionally overwrite __len__(), which is expected to return the size of the dataset by many Sampler implementations and the default options of DataLoader.

Note

DataLoader by default constructs a index sampler that yields integral indices. To make it work with a map-style dataset with non-integral indices/keys, a custom sampler must be provided.

__len__()[source]
__getitem__(idx)[source]
class ontolearn.data_struct.Experience(maxlen: int)[source]

A class to model experiences for Replay Memory.

__len__()[source]
append(e)[source]

Append. :param e: A tuple of s_i, s_j and reward, where s_i and s_j represent refining s_i and reaching s_j.

retrieve()[source]
clear()[source]
class ontolearn.data_struct.NCESBaseDataLoader(vocab, inv_vocab)[source]
static decompose(concept_name: str) list[source]
get_labels(target)[source]
class ontolearn.data_struct.NCESDataLoader(data: list, embeddings, vocab, inv_vocab, shuffle_examples, max_length, example_sizes=None, sorted_examples=True)[source]

Bases: NCESBaseDataLoader, torch.utils.data.Dataset

An abstract class representing a Dataset.

All datasets that represent a map from keys to data samples should subclass it. All subclasses should overwrite __getitem__(), supporting fetching a data sample for a given key. Subclasses could also optionally overwrite __len__(), which is expected to return the size of the dataset by many Sampler implementations and the default options of DataLoader.

Note

DataLoader by default constructs a index sampler that yields integral indices. To make it work with a map-style dataset with non-integral indices/keys, a custom sampler must be provided.

__len__()[source]
__getitem__(idx)[source]
class ontolearn.data_struct.NCESDataLoaderInference(data: list, embeddings, vocab, inv_vocab, shuffle_examples, sorted_examples=True)[source]

Bases: NCESBaseDataLoader, torch.utils.data.Dataset

An abstract class representing a Dataset.

All datasets that represent a map from keys to data samples should subclass it. All subclasses should overwrite __getitem__(), supporting fetching a data sample for a given key. Subclasses could also optionally overwrite __len__(), which is expected to return the size of the dataset by many Sampler implementations and the default options of DataLoader.

Note

DataLoader by default constructs a index sampler that yields integral indices. To make it work with a map-style dataset with non-integral indices/keys, a custom sampler must be provided.

__len__()[source]
__getitem__(idx)[source]
class ontolearn.data_struct.CLIPDataLoader(data: list, embeddings, shuffle_examples, example_sizes: list = None, k=5, sorted_examples=True)[source]

Bases: torch.utils.data.Dataset

An abstract class representing a Dataset.

All datasets that represent a map from keys to data samples should subclass it. All subclasses should overwrite __getitem__(), supporting fetching a data sample for a given key. Subclasses could also optionally overwrite __len__(), which is expected to return the size of the dataset by many Sampler implementations and the default options of DataLoader.

Note

DataLoader by default constructs a index sampler that yields integral indices. To make it work with a map-style dataset with non-integral indices/keys, a custom sampler must be provided.

__len__()[source]
__getitem__(idx)[source]
class ontolearn.data_struct.CLIPDataLoaderInference(data: list, embeddings, shuffle_examples, sorted_examples=True)[source]

Bases: torch.utils.data.Dataset

An abstract class representing a Dataset.

All datasets that represent a map from keys to data samples should subclass it. All subclasses should overwrite __getitem__(), supporting fetching a data sample for a given key. Subclasses could also optionally overwrite __len__(), which is expected to return the size of the dataset by many Sampler implementations and the default options of DataLoader.

Note

DataLoader by default constructs a index sampler that yields integral indices. To make it work with a map-style dataset with non-integral indices/keys, a custom sampler must be provided.

__len__()[source]
__getitem__(idx)[source]