How to split a dataset in v2?

I am trying to run a simple mnist classification with 50% of the training samples.

I created the datasets as this:

splitter = GrandparentSplitter(train_name='training', valid_name='testing')
mnist = DataBlock(blocks=(ImageBlock(PILImageBW), CategoryBlock),
                  get_items=get_image_files, splitter=splitter, get_y=parent_label)
data = mnist.dataloaders(untar_data(URLs.MNIST), bs=64)

I tried to split the train_ds this way:

train_ds_50 = data.train_ds[0:len(data.train_ds)//2]
data.train_ds = train_ds_50  

which leads to error, as one cannot set data.train_ds.

I guess there is a way to do this with transforms, but I cannot find any example in the documentation or the forum.

You’ve got a bunch of splitters here that you can use to do this.

It seems to me that those splitters help you take files in the filesystem and organize in your Datablock. But I already did that. I do have a Datablock with the images. My problem is how to take the train_ds of a Datablock and change it. The code prevents setting a new value directly.