Use a Given PyTorch Data Loader #980
|
Is there a way to use a given PyTorch data loader instead of just a data set? |
Replies: 2 comments 6 replies
|
You cannot pass a You can change the class of the If you want to have control over the actual |
|
To add to @BenjaminBossan's answer:
While true you can also pass a generator function to the net instance that yields from an existing dataloader or constructs one on the fly. def train_iterator(dataset, **kwargs):
loader = DataLoader(dataset, **kwargs)
for X, y in loader:
yield X, y
net = NeuralNet(
...,
iterator_train=train_iterator,
....,
) |
You cannot pass a
DataLoaderinstance tofit.You can change the class of the
DataLoaderby passing it to theiterator_trainanditerator_validargument.If you want to have control over the actual
DataLoaderinstance, you'd have to subclass the net and override theget_iteratormethod. You can check the code, it should be quite straightforward to make it return something custom built.