Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract dataset definition out of the LightningModule #662

Closed
cgarciae opened this issue Jan 4, 2020 · 5 comments
Closed

Extract dataset definition out of the LightningModule #662

cgarciae opened this issue Jan 4, 2020 · 5 comments
Labels
feature Is an improvement or enhancement help wanted Open to be worked on

Comments

@cgarciae
Copy link

cgarciae commented Jan 4, 2020

🚀 Feature

Extract dataset definition out of the LightningModule

Motivation

Separation of data from the model.

Pitch

The datasets loaders could easily be passed to the fit method directly instead of having to define them inside the LightningModule, this avoids having a single class that possibly contains: data, data pipeline params, model, model hyperparams.

The basic example cloud look like this:

from pytorch_lightning import Trainer

train_dataloader = DataLoader(...)
val_dataloader = DataLoader(...)

model = CoolSystem()

# most basic trainer, uses good defaults
trainer = Trainer()    
trainer.fit(model, train_dataloader=train_dataloader, val_dataloader=val_dataloader)

Its much more natural to how you usually structure your code in scikit-learn or keras.

Alternatives

They could also be based to the Trainers constructor.

@cgarciae cgarciae added feature Is an improvement or enhancement help wanted Open to be worked on labels Jan 4, 2020
@williamFalcon
Copy link
Contributor

Why not allow for both? add 3 args to trainer or do it in .fit().

if any of these datasets are passed in the corresponding lightningModule class isn’t called.

thoughts?

@williamFalcon
Copy link
Contributor

@cgarciae want to submit this PR? i agree that we should allow both ways of doing it

@awaelchli
Copy link
Member

@cgarciae can the issue be closed or is there something left to do?

@cgarciae
Copy link
Author

Looks awesome!

@williamFalcon
Copy link
Contributor

williamFalcon commented Feb 26, 2020

@lorenzoFabbri @tullie @myleott @ashwinb @shootingsoul @vreis @Darktex

FYI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Is an improvement or enhancement help wanted Open to be worked on
Projects
None yet
Development

No branches or pull requests

3 participants