Problem
LightningDataModule을 다루면서 나타난 에러인데, 처음엔 단순히 prepare_data 함수를 정의하지 않아서 발생한 문제인 줄 알았는데, 해당 함수를 정의했음에도 불구하고 다른 _has_~~~ 에러들이 발생했다.
AttributeError: 'YourDataModule' object has no attribute '_has_prepared_data'
Solution
해결방법은 굉장히 간단했는데, LightningDataModule의 init안에 super().__init__()를 작성하면 바로 해결이 된다.
def __init__(self, root, batchsize = 16,num_workers=24):
super().__init__()
self.root = root
self.batchsize = batchsize
self.num_workers = num_workers
- Reference
Warn when you forget to call super().__init__() in datamodule subclass · Issue #3175 · PyTorchLightning/pytorch-lightning
🚀 Feature If you forget to call super().__init__() in datamodule subclass, you end up getting confusing errors down the line. We should let the user know they've forgotten to do so and give the...
github.com
'인공지능 > Python' 카테고리의 다른 글
change edge thickness (using opencv Morphological Transformations ) (0) | 2022.05.16 |
---|---|
gray scale image to RGB image (using opencv) (0) | 2022.05.16 |
LightningDataModule을 for loop에서 이용하는 방법 (0) | 2022.05.13 |
Warning: find_unused_parameters=True 해결방법 (DDP programming) (0) | 2022.05.13 |
Data Parallel(DP), Distributed Data Parallel(DDP)의 차이 (0) | 2022.05.04 |