self.log
raised error when number of dataloader is not consistent
#16350
Unanswered
ding3820
asked this question in
Lightning Trainer API: Trainer, LightningModule, LightningDataModule
Replies: 0 comments
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.
-
Hi all,
Recently I've been modifying our codes to adopt the latest lightning logging approach that is
self.log
. We have two validation dataloaders, A and B. For A we use it every epoch. But for B, we use it every 5 epoch. We implement this mechanism inval_dataloader()
and reload dataloader every epoch. See below for implementation.However, when we use self.log in validation_step(), an error shows up
(see here)
After debug in the source code, I notice that when we are at the epoch that only use one val dataloader,
dataloader_idx
is alwaysNone
. On the other hand, when we have two val dataloaders,dataloader_idx
would be sequentially presented as 0 or 1 in validation_step. If I understand correctly, this is the main reason causing the error.The questions are how can I avoid this error. Is it a lightning implementation issue? Is there any better way to implement it? I'm open for any suggestions. Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions