Hi,
I developed the following code to concatenate two data together. I received correct answer on my local machine, while google colab did not send correct answer. Please advice
class ConcatDataset(Dataset):
  def __init__(self, x1, x2, y): self.x1, self.x2, self.y = x1, x2, y
  def __len__(self): return len(self.y)
  def __getitem__(self, i): return (self.x1[i], self.x2[i]), self.y[i]

#concatenate base and target dataset
train_ds = ConcatDataset(x1_train, x2_train, y_train)
valid_ds = ConcatDataset(x1_valid, x2_valid, y_valid)

#create training and validation data loaders from train and valid dataset
train_dl = DataLoader(train_ds, batch_size=2)
valid_dl = DataLoader(valid_ds, batch_size=2)

#create train data bunch from training and validation data loaders
data_train = DataBunch(train_dl, valid_dl)

from torchvision.utils import make_grid
def imshow(inp): plt.imshow(np.clip(inp.numpy().transpose((1, 2, 0)), 0, 1))
(x1, x2), y = next(iter(data_train.train_dl)); concat = torch.cat((x1, x2), 0); plt.figure(figsize = (24, 9)); imshow(make_grid(concat, nrow=2))

Google Colab Concatenation Sample Result (Wrong Concatenation):
image529×524 87.9 KB
My Local Machine Concatenation Sample Result (Correct Concatenation):
image529×524 99.1 KB