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

AttributeError: BinaryMNISTDataModule object has no attribute train_transforms #934

Closed
davidgilbertson opened this issue Nov 2, 2022 · 1 comment
Assignees
Labels
help wanted Extra attention is needed

Comments

@davidgilbertson
Copy link

🐛 Bug

To Reproduce

Trying to run the code from the docs here: https://lightning-bolts.readthedocs.io/en/stable/datamodules/vision.html#binarymnist

Steps to reproduce the behavior: Run the code from that page:

from pl_bolts.datamodules import BinaryMNISTDataModule

dm = BinaryMNISTDataModule('.')
model = LitModel()

Trainer().fit(model, datamodule=dm)

Expected behavior

It shouldn't error :)

Environment

pytorch-lightning: 1.7.7
lightning-bolts: 0.5.0

Additional context

Adding this makes it work:

dm = BinaryMNISTDataModule(".")
dm.train_transforms = None
dm.val_transforms = None
...

This check (and the val counterpart) are assuming the existence of an attribute that isn't defined as a default.

train_transforms = self.default_transforms() if self.train_transforms is None else self.train_transforms

From https://github.com/Lightning-AI/lightning-bolts/blob/master/pl_bolts/datamodules/vision_datamodule.py#L103

I don't know the codebase well, but it looks like either train_transforms should have a default value, or a hasattr() check should be added, or query the value with a fallback, like if getattr(self, 'train_transforms', None) is None

Or maybe I'm doing something wrong. The docs have this cryptic little message about transforms, with no context. What is this saying, what is transform_lib, what am I supposed to do with mnist_transforms?

image

@davidgilbertson davidgilbertson added the help wanted Extra attention is needed label Nov 2, 2022
@Borda Borda changed the title AttributeError: 'BinaryMNISTDataModule' object has no attribute 'train_transforms' AttributeError: BinaryMNISTDataModule object has no attribute train_transforms Nov 2, 2022
@otaj
Copy link
Contributor

otaj commented Nov 4, 2022

Hi, @davidgilbertson. This is happening because pytorch-lightning>=1.7.0 removed these methods and lightning-bolts==0.5.0 was released quite some time ago.

If you update to lightning-bolts==0.6.0, this should be fixed. We made sure we're being a bit more compatible with current version.

OTOH, beware please, that if you use 0.6.0, you will get quite a bit of warnings originating from our package, this is mainly due to issue #839. They should be harmless, but there will be quite many of them

@otaj otaj closed this as completed Nov 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants