:py:mod:`ontolearn.data_struct` =============================== .. py:module:: ontolearn.data_struct .. autoapi-nested-parse:: Data structures. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: ontolearn.data_struct.PrepareBatchOfPrediction ontolearn.data_struct.PrepareBatchOfTraining ontolearn.data_struct.Experience ontolearn.data_struct.NCESBaseDataLoader ontolearn.data_struct.NCESDataLoader ontolearn.data_struct.NCESDataLoaderInference ontolearn.data_struct.CLIPDataLoader ontolearn.data_struct.CLIPDataLoaderInference .. py:class:: PrepareBatchOfPrediction(current_state: torch.FloatTensor, next_state_batch: torch.FloatTensor, p: torch.FloatTensor, n: torch.FloatTensor) Bases: :py:obj:`torch.utils.data.Dataset` An abstract class representing a :class:`Dataset`. All datasets that represent a map from keys to data samples should subclass it. All subclasses should overwrite :meth:`__getitem__`, supporting fetching a data sample for a given key. Subclasses could also optionally overwrite :meth:`__len__`, which is expected to return the size of the dataset by many :class:`~torch.utils.data.Sampler` implementations and the default options of :class:`~torch.utils.data.DataLoader`. .. note:: :class:`~torch.utils.data.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. .. py:method:: __len__() .. py:method:: __getitem__(idx) .. py:method:: get_all() .. py:class:: PrepareBatchOfTraining(current_state_batch: torch.Tensor, next_state_batch: torch.Tensor, p: torch.Tensor, n: torch.Tensor, q: torch.Tensor) Bases: :py:obj:`torch.utils.data.Dataset` An abstract class representing a :class:`Dataset`. All datasets that represent a map from keys to data samples should subclass it. All subclasses should overwrite :meth:`__getitem__`, supporting fetching a data sample for a given key. Subclasses could also optionally overwrite :meth:`__len__`, which is expected to return the size of the dataset by many :class:`~torch.utils.data.Sampler` implementations and the default options of :class:`~torch.utils.data.DataLoader`. .. note:: :class:`~torch.utils.data.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. .. py:method:: __len__() .. py:method:: __getitem__(idx) .. py:class:: Experience(maxlen: int) A class to model experiences for Replay Memory. .. py:method:: __len__() .. py:method:: append(e) 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. .. py:method:: retrieve() .. py:method:: clear() .. py:class:: NCESBaseDataLoader(vocab, inv_vocab) .. py:method:: decompose(concept_name: str) -> list :staticmethod: .. py:method:: get_labels(target) .. py:class:: NCESDataLoader(data: list, embeddings, vocab, inv_vocab, shuffle_examples, max_length, example_sizes=None, sorted_examples=True) Bases: :py:obj:`NCESBaseDataLoader`, :py:obj:`torch.utils.data.Dataset` An abstract class representing a :class:`Dataset`. All datasets that represent a map from keys to data samples should subclass it. All subclasses should overwrite :meth:`__getitem__`, supporting fetching a data sample for a given key. Subclasses could also optionally overwrite :meth:`__len__`, which is expected to return the size of the dataset by many :class:`~torch.utils.data.Sampler` implementations and the default options of :class:`~torch.utils.data.DataLoader`. .. note:: :class:`~torch.utils.data.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. .. py:method:: __len__() .. py:method:: __getitem__(idx) .. py:class:: NCESDataLoaderInference(data: list, embeddings, vocab, inv_vocab, shuffle_examples, sorted_examples=True) Bases: :py:obj:`NCESBaseDataLoader`, :py:obj:`torch.utils.data.Dataset` An abstract class representing a :class:`Dataset`. All datasets that represent a map from keys to data samples should subclass it. All subclasses should overwrite :meth:`__getitem__`, supporting fetching a data sample for a given key. Subclasses could also optionally overwrite :meth:`__len__`, which is expected to return the size of the dataset by many :class:`~torch.utils.data.Sampler` implementations and the default options of :class:`~torch.utils.data.DataLoader`. .. note:: :class:`~torch.utils.data.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. .. py:method:: __len__() .. py:method:: __getitem__(idx) .. py:class:: CLIPDataLoader(data: list, embeddings, shuffle_examples, example_sizes: list = None, k=5, sorted_examples=True) Bases: :py:obj:`torch.utils.data.Dataset` An abstract class representing a :class:`Dataset`. All datasets that represent a map from keys to data samples should subclass it. All subclasses should overwrite :meth:`__getitem__`, supporting fetching a data sample for a given key. Subclasses could also optionally overwrite :meth:`__len__`, which is expected to return the size of the dataset by many :class:`~torch.utils.data.Sampler` implementations and the default options of :class:`~torch.utils.data.DataLoader`. .. note:: :class:`~torch.utils.data.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. .. py:method:: __len__() .. py:method:: __getitem__(idx) .. py:class:: CLIPDataLoaderInference(data: list, embeddings, shuffle_examples, sorted_examples=True) Bases: :py:obj:`torch.utils.data.Dataset` An abstract class representing a :class:`Dataset`. All datasets that represent a map from keys to data samples should subclass it. All subclasses should overwrite :meth:`__getitem__`, supporting fetching a data sample for a given key. Subclasses could also optionally overwrite :meth:`__len__`, which is expected to return the size of the dataset by many :class:`~torch.utils.data.Sampler` implementations and the default options of :class:`~torch.utils.data.DataLoader`. .. note:: :class:`~torch.utils.data.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. .. py:method:: __len__() .. py:method:: __getitem__(idx)