Fastai: Export data loader with data from pytorch Dataloaders

Created on 18 Feb 2019  路  3Comments  路  Source: fastai/fastai

I am using fastai 1.0.42. When I call learner.export() I get the following error:

    state['data'] = self.data.valid_ds.get_state(**xtra)
AttributeError: 'ImageFolder' object has no attribute 'get_state'

My code looks like

```python
data = DataBunch(train_dl=train_dl, valid_dl=val_dl, test_dl=test_dl)
learner = Learner(data=data,
model=model,
path='/foo/',
model_dir='/foo/model',
loss_func=criterion,
metrics=[accuracy])

``

This is probably due to the fact that train_dl, val_dl and test_dl are instances of DataLoader. Is there a work around?

Thank you

All 3 comments

If you don't use the fastai library to build your DataLoader through the data block API, this functionality won't work, no.
You will have to create a Learner yourself at inference and load the model with learn.load(...).

The doc is horrible, any proper suggestion to build the dataloader using the fastai API keeping in mind that train, test and val data are in three different folders? I also want to apply a custom transformation to each dataloader.

These operations are really easy with vanilla Pytorch, I have wasted two hours trying to understand how to do so.

This behavior is inconsistent with the standards we set it the code of conduct. Please do not contribute any further to this community if you are not able to change your conduct in the future.

Was this page helpful?
0 / 5 - 0 ratings