TheShadow29 / FAI-notes

Some notes, tutorials, and some experimentation with the fast.ai library (https://github.com/fastai/fastai)
58 stars 15 forks source link

How can I use the WeightedRandomSampler in fastai fit func? #1

Closed robeson1010 closed 6 years ago

TheShadow29 commented 6 years ago

Are you using new fastai (v1) or the older one (0.7)? Both would have similar approach. Define a DataLoader, and then pass it to the DataBunch (for v1) and ModelData for (v0.7).

To be specific:

trn_dl = DataLoader(trn_ds, sampler=sampler)
val_dl = DataLoader(val_ds, sampler=sampler)
data = DataBunch(trn_dl, val_dl, path=path)

In the older one use data = ModelData(path, trn_dl, val_dl).

robeson1010 commented 6 years ago

Thanks~

TheShadow29 commented 6 years ago

Closing the issue then.