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

SwAV example not working #818

Closed
sirtris opened this issue Mar 29, 2022 · 2 comments · Fixed by #960
Closed

SwAV example not working #818

sirtris opened this issue Mar 29, 2022 · 2 comments · Fixed by #960
Labels
won't fix This will not be worked on

Comments

@sirtris
Copy link

sirtris commented Mar 29, 2022

Hello,
I was trying to get the lightning_bolts SwAV example running. unfortunately the example code does not work.

import pytorch_lightning as pl
from pl_bolts.models.self_supervised import SwAV
from pl_bolts.datamodules import STL10DataModule
from pl_bolts.models.self_supervised.swav.transforms import (
    SwAVTrainDataTransform, SwAVEvalDataTransform
)
from pl_bolts.transforms.dataset_normalizations import stl10_normalization

# data
batch_size = 128
dm = STL10DataModule(data_dir='.', batch_size=batch_size)
dm.train_dataloader = dm.train_dataloader_mixed
dm.val_dataloader = dm.val_dataloader_mixed

dm.train_transforms = SwAVTrainDataTransform(
    normalize=stl10_normalization()
)

dm.val_transforms = SwAVEvalDataTransform(
    normalize=stl10_normalization()
)

# model
model = SwAV(
    gpus=1,
    num_samples=dm.num_unlabeled_samples,
    dataset='stl10',
    batch_size=batch_size
)

# fit
trainer = pl.Trainer(precision=16)
trainer.fit(model)

the fit function is missing the data module. It should be:
trainer.fit(model, datamodule=dm)

But even then I get the following error message:
RuntimeError: The size of tensor a (128) must match the size of tensor b (0) at non-singleton dimension 0

How can i fix that?
THX

@sirtris
Copy link
Author

sirtris commented Apr 13, 2022

Any tips on this?
How could I debug this?

Any go on fixing the docs?

@stale
Copy link

stale bot commented Jun 15, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the won't fix This will not be worked on label Jun 15, 2022
@stale stale bot closed this as completed Jun 28, 2022
@eggry eggry mentioned this issue Jan 12, 2023
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
won't fix This will not be worked on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant