Is TensorDataset significantly slower than standard Dataset?


(Wei Chen) #1

Hi, I am using the same model with two following data loading strategy:

train_loader = DataLoader(TensorDataset(train_0, train_t), batch_size=batch_size, 
                        shuffle=True, drop_last=False)
train_loader = DataLoader(torch.cat((train_0, train_t), dim=1), batch_size=batch_size, 
                        shuffle=True, drop_last=False)

I trained both cases for 2 epochs, and case 1 took 30 seconds while case 2 took only 13 s. Does anyone know why there would be a significant difference between these two?

Thanks!