https://github.com/facebookresearch/pythia
Raw File
Tip revision: ff5c63f8fafa0320d6646340a434497bf7e22718 authored by Vedanuj Goswami on 17 December 2020, 16:21:30 UTC
[docs] Docs for various MMF Transformer configurations
Tip revision: ff5c63f
subset_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates.

from torch.utils.data.dataset import Subset


class MMFSubset(Subset):
    def __init__(self, dataset, indices):
        super().__init__(dataset, indices)
        self._dir_representation = dir(self)

    def __getattr__(self, name):
        if "_dir_representation" in self.__dict__ and name in self._dir_representation:
            return getattr(self, name)
        elif "dataset" in self.__dict__ and hasattr(self.dataset, name):
            return getattr(self.dataset, name)
        else:
            raise AttributeError(name)
back to top