timesead.data.dataset ===================== .. py:module:: timesead.data.dataset Classes ------- .. autoapisummary:: timesead.data.dataset.BaseTSDataset Functions --------- .. autoapisummary:: timesead.data.dataset.collate_fn Module Contents --------------- .. py:class:: BaseTSDataset Bases: :py:obj:`abc.ABC`, :py:obj:`torch.utils.data.Dataset` Base class for all time-series datasets in TimeSeAD. Implementing the members in this abstract class provides the data pipeline system with the necessary information to process the data correctly. .. py:method:: __len__() -> int :abstractmethod: This should return the number of independent time series in the dataset .. py:property:: seq_len :type: Union[int, List[int]] :abstractmethod: This should return the length of each time series. If the time series have different lengths, the return value should be a list that contains the length of each sequence. If all sequences are of equal length, this should return an int. .. py:property:: num_features :type: Union[int, Tuple[int, Ellipsis]] :abstractmethod: Number of features of each datapoint. This can also be a tuple if the data has more than one feature dimension. .. py:method:: get_default_pipeline() -> Dict[str, Dict[str, Any]] :staticmethod: :abstractmethod: Return the default pipeline for this dataset that is used if the user does not specify a different pipeline. This must be a dict of the form:: { '': {'class': '', 'args': {'', ...}}, ... } .. py:method:: get_feature_names() -> List[str] :staticmethod: :abstractmethod: Return names for the features in the order they are present in the data tensors. :return: A list of strings with names for each feature. .. py:method:: __getitem__(index: int) -> Tuple[Tuple[torch.Tensor, Ellipsis], Tuple[torch.Tensor, Ellipsis]] :abstractmethod: Access the timeseries at position `index` and its corresponding label sequence. A call to this function should return a single time series that was sampled independently of the other time series in this dataset. :param index: The zero-based index of the time series to retrieve. :return: A tuple `(inputs, targets)`, where inputs is again a tuple of :class:`~torch.Tensor`\s with shape `(T, D*)`, where `D*` can very between the tensors. `targets` contains labels for the time series as tensors of shape `(T,)`. .. py:function:: collate_fn(batch_dim: int) -> Callable Puts each data field into a tensor with outer dimension batch size. This was largely copied from PyTorch's :func:`~torch.utils.data._utils.default_collate` function except that it allows concatenating :class:`~torch.Tensor`\s along an arbitrary dimension instead of always stacking along the first dimension. :param batch_dim: The index of the dimension along which to stack the elements in the batch. :return: Batched tensors where elements have been stacked along the `batch_dim` dimension.