How to convert raster image + shape files to a segmentation problem?

I have a problem converting raster image + shape files containing polygons and the class of each one to a segmentation problem to be able to classify crops.

The data I have is composed of a raster image which is composed of 13 bands, train polygons that have known classes and the test polygons that I don’t know the class. I want to convert that raster to images of shape 13 * 256 * 256 with mask of shape 1 * 256 * 256.

My problem is that the test and train polygons are not in separate raster images, so if I will produce images with a mask indicating the class it will overlap with pixels belonging the test data that I don’t know the class. -I though of assigning a different class to this test pixels but this affects the learning of the model as they really belong to another class. -Other solution that I think will work better is to only mask training data and construct images of shape 13* biggest(width, height) but the range of width and height is too large from 3 pixels to 202. So there would be images with too much zero pixels.

Is there other solutions for such a problem.
Thank you in advance.