# WeightedRandomSampler in PyTorch\_Geometric Dataloader

**URL:** <https://discuss.pytorch.org/t/weightedrandomsampler-in-pytorch-geometric-dataloader/119358>\
**Category:** Uncategorized\
**Created:** [April 25, 2021, 2:16pm UTC](https://discuss.pytorch.org/t/weightedrandomsampler-in-pytorch-geometric-dataloader/119358 "2021-04-25T14:16:40Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![ptrblck](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ptrblck/32/1823_2.png) [@ptrblck](https://discuss.pytorch.org/u/ptrblck)\
**Post date:** [April 26, 2021, 5:07am UTC](https://discuss.pytorch.org/t/weightedrandomsampler-in-pytorch-geometric-dataloader/119358/2 "2021-04-26T05:07:09Z")

</div>

I’m not familiar with PyTorch Geometric, but in case you can precompute the targets and each sample has one corresponding target class, you could take a look at [this code snippet](https://discuss.pytorch.org/t/how-to-handle-imbalanced-classes/11264/2), which explains the usage of the `WeightedRandomSampler`.

---

_[View the full topic](https://discuss.pytorch.org/t/weightedrandomsampler-in-pytorch-geometric-dataloader/119358)._
