I would like to truncate the dataloader to run epochs faster for testing purposes.
My attemp so far was using itertools islice:
from itertools import islice
# Testing mode
    if test:         
        trainloader = islice(trainloader, 20)

However, this gives problems since iterators has no len method for example, and I need to be changing code depending of if I am testing or not.
Is there any “official” way of dealing with PyTorch Dataloaders?
And btw, are PyTorch Dataloaders Python Iterable type?
Thanks!