Folder Structure for VicRegL
ramdhan1989 opened this issue · 2 comments
Hi I got this error when following ViCRegL tutorial, I think it was coming from dataloader with error as follow? I used my own dataset. I wonder how the correct folder structure for this model?
`Starting Training
0%| | 0/255 [00:27<?, ?it/s]
AttributeError Traceback (most recent call last)
Cell In[5], line 5
3 total_loss = 0
4 for views_and_grids in tqdm(dataloader):
----> 5 views_and_grids = [x.to(device) for x in views_and_grids]
6 views = views_and_grids[: len(views_and_grids) // 2]
7 grids = views_and_grids[len(views_and_grids) // 2 :]
Cell In[5], line 5, in (.0)
3 total_loss = 0
4 for views_and_grids in tqdm(dataloader):
----> 5 views_and_grids = [x.to(device) for x in views_and_grids]
6 views = views_and_grids[: len(views_and_grids) // 2]
7 grids = views_and_grids[len(views_and_grids) // 2 :]
AttributeError: 'list' object has no attribute 'to'`
and this is my dataloader
`transform = VICRegLTransform(n_local_views=0)
path = 'D:/xxx/images/'
dataset = data.LightlyDataset(path, transform=transform)
dataloader = torch.utils.data.DataLoader(
dataset,
batch_size=256,
shuffle=True,
drop_last=True,
num_workers=8,
)`
inside folder "images" there is another one folder containing images
Thank you
The dataloader should return batches with type tuple[list[Tensor], Tensor]
. Tensor
are the targets/labels of the images and list[Tensor]
contains the different augmented views of the images. Every Tensor
in list[Tensor]
is one view of the batch.
I believe you have to change the iteration code over the dataloader slightly. This might work:
for batch in tqdm(dataloader): # batch is a tuple[list[Tensor], Tensor]
views_and_grids = batch[0]. # views_and_grids is a list[Tensor]
views_and_grids = [x.to(device) for x in views_and_grids]
I'll close this for now, please reopen if you encounter more issues.