I am quite new to pytorch, and I am trying to create data within a dataloader and my code looks like so:
a=[]
.. within a for loop
self.a.append(torch.stack([b[ith_idx][j], \
b[ith_idx][rnd_dist], \
b[rnd_cls_idx][rnd_dist_rnd_cls]]\
))
self.c.append([1,0])
where, b is a python list of tensors. For example, the first element of b
has shape torch.Size([46, 3, 512, 512])
.
self.a = torch.stack(self.a)
self.c = torch.tensor(self.c)
and I notice I have shapes of [500,3,3,512,512]
and [500,2] for a
and b
, while I was expecting 500,3,3,512,512
and 500
as tensor shapes.
Any pointers as to why this is happening would be helpful.