dreamer:

train_x=torch.Tensor(train_x) #train_x=train_x.view(-1,1,3) train_x=train_x.view(77,1,16,16,3) train_y=torch.Tensor(train_y) train_y=train_y.view(77,1,16,16)


Based on the above code, you changing the sizes, before this, val and train are consistent. If you want to extract val dataset, first do the size changing then extract val.



 dreamer:

train x size: torch.Size([77, 1, 16, 16, 3]) train y size: torch.Size([77, 1, 16, 16]) val x size: torch.Size([3465, 1, 3]) val y size: torch.Size([3465, 1])


First, just separate your x and y, then do the dimension changes as you want, the extract val using list comprehension which you already have done. In this situation the sizes should be consistent.
Note that we always extract train, test and val set from same source so they all have to be same thing.