2020-10-13 11:18:07 +00:00
|
|
|
# Copyright The PyTorch Lightning team.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
2020-04-16 02:16:40 +00:00
|
|
|
from abc import ABC, abstractmethod
|
|
|
|
|
2020-05-10 17:15:28 +00:00
|
|
|
from tests.base.dataloaders import CustomInfDataloader
|
2020-06-20 03:38:15 +00:00
|
|
|
from tests.base.dataloaders import CustomNotImplementedErrorDataloader
|
2020-05-05 16:31:15 +00:00
|
|
|
|
2020-04-16 02:16:40 +00:00
|
|
|
|
|
|
|
class TrainDataloaderVariations(ABC):
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
def dataloader(self, train: bool):
|
|
|
|
"""placeholder"""
|
|
|
|
|
|
|
|
def train_dataloader(self):
|
|
|
|
return self.dataloader(train=True)
|
2020-05-05 16:31:15 +00:00
|
|
|
|
|
|
|
def train_dataloader__infinite(self):
|
|
|
|
return CustomInfDataloader(self.dataloader(train=True))
|
|
|
|
|
2020-06-20 03:38:15 +00:00
|
|
|
def train_dataloader__not_implemented_error(self):
|
|
|
|
return CustomNotImplementedErrorDataloader(self.dataloader(train=True))
|
|
|
|
|
2020-05-05 16:31:15 +00:00
|
|
|
def train_dataloader__zero_length(self):
|
|
|
|
dataloader = self.dataloader(train=True)
|
|
|
|
dataloader.dataset.data = dataloader.dataset.data[:0]
|
|
|
|
dataloader.dataset.targets = dataloader.dataset.targets[:0]
|
|
|
|
return dataloader
|