Use a Given PyTorch Data Loader #980
-
Is there a way to use a given PyTorch data loader instead of just a data set? |
Beta Was this translation helpful? Give feedback.
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 |
Beta Was this translation helpful? Give feedback.
-
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,
....,
) |
Beta Was this translation helpful? Give feedback.
You cannot pass a
DataLoader
instance tofit
.You can change the class of the
DataLoader
by passing it to theiterator_train
anditerator_valid
argument.If you want to have control over the actual
DataLoader
instance, you'd have to subclass the net and override theget_iterator
method. You can check the code, it should be quite straightforward to make it return something custom built.