ITADN

LightningDataModule xxx_dataloader must be realize?

#21684OpenFranticEr 创建于 2026-04-24
featureneeds triage
F
FranticErcommented
### Description & Motivation I'm encountering inconsistent behavior in PyTorch Lightning when dealing with validation datasets. When I don't have a validation set: Not implementing the val_dataloader method: The program runs correctly Implementing val_dataloaderand returning None: Throws TypeError: object of type 'NoneType' has no len() According to PyTorch Lightning's design, the Trainer.fit()method itself allows not passing a validation data loader. In fact, if I don't implement the val_dataloadermethod, the program runs correctly. But when I implement this method and return Nonewhen there's no validation set, I get an error. 你们应该在获取val_dataloader时去检查其类型吗,按照val_dataloader=None的逻辑走吗?你们的fit实现中也会检查是不是None 或者提供一个专有的异常类来提示val_dataloader是空,进而处理吗 ### Pitch _No response_ ### Alternatives _No response_ ### Additional context _No response_ cc @lantiga
0 条评论