Evaluating on multiple tasks in continual learning setup. #11932
Unanswered
prateeky2806
asked this question in
Lightning Trainer API: Trainer, LightningModule, LightningDataModule
Replies: 1 comment
-
for such a case, I'd suggest extracting the loaders from your datamodule and passing each dataloader from 1 to k explicitly. for i in range(1, k):
val_dl = datamodule.loaders[i]
res = trainer.validate(model, dataloaders=val_dl) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Everyone, this is my first project in PyTorch lightning and I am working on a problem related to continual learning. During training I have multiple Tasks (Datasets A, B, C, D) which are used sequentially in the training. Now, whenever I am switching from task x to task y, I want to evaluate the performance on the validation on all the previous and future tasks.
My Datamodule looks something like this, where I have a method update_task(task_id) which updates the dataloaders to the correct task and also resets the train and val dataloaders whenever it is called.
I am using a logic like this to perform the training. I am using on_train_epoch_start to switch the dataloaders every k epochs.
Now after every k epoch, Now from epoch 1-k I am performing validation on task 1 but at the kth epoch I also want to validate on all the other tasks as well (A,B,C,D). In pure pytorch it would look something like this.
I am not sure how to go about this in pytorch lightning, specifically how to get manually iterate over dataloader in lightning as currently I just work wby defining validation and training steps which takes care of iterating over the dataloader internally. I tried to do it myself manually but then I get errors regarding tensors on being on right devices. Any help would be highly appreciated! Thanks in Advance.
Beta Was this translation helpful? Give feedback.
All reactions