How to create a dataloader for dictionary

Hi, I have a dictionary as dataset. How to use this as data in training a pytorch model

In general pytorch doesn’t really care what python structures you use to store your data. The main caveat here is that when you create the dataloader you may need to specify a collate_fn which takes the individual samples and combines them into a batch.

See https://pytorch.org/docs/stable/data.html#dataloader-collate-fn for more details on how you define that.

Can write up a simple example later if that isn’t clear.

1 Like