AttributeError: module 'torch.utils.data' has no attribute 'random_split

Hello ,
I am getting error “AttributeError: module ‘torch.utils.data’ has no attribute 'random_split”

in following code.

train_dataset, test_dataset = torch.utils.data.random_split(full_dataset, [train_size, test_size])

Anybody know the reason ?
My torch.utils.data does not suggest random_split in import section even.

Which PyTorch version are you using?
You can check it using print(torch.__version__).
The current stable version is 1.1.0, so if you are using an older one, I would recommend to install the latest version following the instructions from the website.

1 Like

Thank you verymuch.
I upgraded the version and now it is working.

Thanks…

1 Like