import torch
from torchvision.datasets import MNIST
transform = transforms.Compose([transforms.ToTensor(), 
                                        transforms.Normalize((0.5,), (0.5,))])
dataset = MNIST(root = './data', train = train, transform = transform, download=True)
train_set, val_set = torch.utils.data.random_split(dataset, [50000, 10000])

The function of random_split to split the dataset is not working. The size of train_set and val_set returned are both 60000 which is equal to the initial dataset size.
A similar error is also reported on stack overflow:

  
      stackoverflow.com
  
  
      
    
  

  torch.utils.data.random_split() is not splitting the data 186



  deep-learning, pytorch



  asked by
  
  
    user9625519
  
  on 01:37PM - 04 Sep 19 UTC


  
  
    
    
  
  


Please look into the issue.
Thanks.