Add validation set to image segmentation model fit?

Have tried to figure out how to add a validation set to the model.fit() call in the image segmentation task.

Should the following work? I was just interested to see whether we are really overfitting or not.

train_ds = train_dataset.take(30) 
val_ds = train_dataset.skip(30)

model_history = unet.fit(train_ds, validation_data = val_ds,  epochs=EPOCHS)

The 30 number is based on the fact that the train_dataset object is a BatchDataset with 34 lots of (mostly) 32 inputs. So taking first 30 gives me 30*32= 960 training examples, leaving 1080-960 = 120 to test on.

Your approach will work.

If there are 1080 images, the split is around 89% for train and < 11% for test. So, you might want to change to something like, say, 70-30.